mac_gabe Posted November 8, 2010 Share Posted November 8, 2010 Apologies, I'm a complete beginner, so don't even know what to search for, I'm sure this is really elementary level. I've got html text on a second page which I want to "include" in the main php web page and do a "string replace" on at the same time. I can do the "include" OK on its own, but can't get the "string replace" to work at the same time, it just returns the unaltered text. I then want to do something quite a bit more complicated but need to get over this hurdle first. Many thanks for any help. <?php $sidebar = 'index_files/sidebar-content2.html'; echo str_replace("Auks", "Penguins", include $sidebar); ?> Quote Link to comment https://forums.phpfreaks.com/topic/218098-beginner-str_replace-and-include/ Share on other sites More sharing options...
salathe Posted November 8, 2010 Share Posted November 8, 2010 include() will evaluate the file as PHP (if there is no PHP in there, then it will just be outputted). To retrieve the contents of the file, the file_get_contents function should be used. Quote Link to comment https://forums.phpfreaks.com/topic/218098-beginner-str_replace-and-include/#findComment-1131739 Share on other sites More sharing options...
mac_gabe Posted November 8, 2010 Author Share Posted November 8, 2010 It works! Many thanks Now I will try to work out a more complex search and replace, will return if I have any more problems. Great forum! Quote Link to comment https://forums.phpfreaks.com/topic/218098-beginner-str_replace-and-include/#findComment-1131740 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.