Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Integrating PHP with Databases Limiting Records in SQL Filtering Data by Category

James Fisher
James Fisher
29,163 Points

Nested replace? little more information?

Wish she talked more about a "Nested replace" - Project jumps around a lot and doesn't explain the logic behind the code

1 Answer

Steven Parker
Steven Parker
231,268 Points

The term "nested replace" just refers to using one REPLACE function as the source for another REPLACE. This can be done several times, as needed. Each REPLACE function changes (or removes) one word or phrase from the string field and passes the result on to the next one.

Each one is done in turn, starting with the one most deeply nested (and which uses the field itself as a source), and ending with the outer one. Notice how indentation is used in the code to visually indicate the nesting level.