x_maras Posted March 29, 2009 Share Posted March 29, 2009 Hi, is it possible to change a word of a text or some part of it with php? for example if I ve got this file temp.txt and in the text there is a word "change" can I change it with this: $text="something" ? I think I would be possible with regexps, I looked but I don't know where exactly to look. If you could give me an example or link me somewhere would be very helpfull. Thanks Link to comment https://forums.phpfreaks.com/topic/151601-changing-text-with-php/ Share on other sites More sharing options...
killah Posted March 29, 2009 Share Posted March 29, 2009 str_replace $file = file_get_contents('temp.txt'); $replace = 'change'; $with = 'changed'; $new = str_replace($replace,$with,$file); echo $new; Link to comment https://forums.phpfreaks.com/topic/151601-changing-text-with-php/#findComment-796214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.