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

I need the "ANSWER" not the "HINT" Please & Thank you!

Open the file http://getauto.com/robots.txt. Once you open the file count the number of times the word “getauto” appear in the file and the line number of the files. And then replace the word “getauto” with “myauto” and print the output of file in upper case.

I HAVE NO IDEA HOW TO DO THIS, please leave ANSWER in the comments. I understand you want to hint me, but please leave an ANSWER!

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Outsourcing your work or sub-contracting generally involves a fee. I was under the impression that this is a learning community. Just speaking for myself here, maybe others are interested in doing your tasks.

Even if one were to simply provide an answer for how to do this, the instructions aren't entirely clear.

Either way, if you want a simple find and replace, one solution is to drop the content in a text editor and use the resident find and replace feature. Or is there some reason this has to be done programatically? Again, not entirely clear.

Good luck, and may the odds be ever in your favor.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Sekoyya Little

Sorry, but the Community is not meant to just "give the answer". It is a place to come for assistance and guidance, be it with hints, links, suggestion, etc. Sometimes, threads will turn into very lengthy conversations with other students as they help you to gain a better understanding of the subject matter, which can prove to be even more valuable to others looking at the thread.
If you're really stuck, then reviewing the videos (some I've watched more than a few times and still do), using Google to find others with similar situations or errors (this is very popular in the industry), checking Stack Overflow, etc really is the best way to learn.
In the real-world, you are likely not going to have someone be able to just "give you the answer" when you are stuck. Your employer / client will expect you to be resourceful enough to come up with the answer, as you are the one they hired. I understand learning can get tough, but in coding, you will always be learning so it's best now to also learn how to utilize all the resources available to solve a problem. This is the best way to become a successful coder and is the kind of environment that Treehouse strives to provide. :)

And Dave varmutant is pretty much correct... the Community is meant to help you learn and understand, not do it for you. Especially since this does not look as though it is a Treehouse Challenge (If it is, please provide the link to the challenge).

I hope you find what you need. :)

Jason ~Treehouse Community Moderator~

1 Answer

What everybody else said so while it is explicitly what you didn't ask for it's what you need: use cURL / Guzzle (uses cURL by default but is a very nice wrapper) to fetch the file. You can save it as a new file if you would like. Then if you saved it as a file you can use fopen, fgets, str_replace, and fwrite to make a new one or save over the old with your revisions.

Hopefully, this is enough that with 10-15 minutes of Google Fu you'll be well on your way to a working program. Added benefit: Once you know this you can apply it to any content you can navigate to on the internet which opens up a literal and figurative world of possibilities.