millercj Posted March 20, 2009 Share Posted March 20, 2009 Hi i'm looking for some guidance on a how-to if this is possible. I want to edit a text file at specific points such as let say this is my file: Hello: 5 Goodbye: 3 I know how to get the values (5 and 3) by using pregmatch() but is there a way that (using some sort of If statement) if a condition is true, Increment a value and return/save it to the respective tag (Hello or Goodbye) Link to comment https://forums.phpfreaks.com/topic/150315-edit-text-file/ Share on other sites More sharing options...
rhodesa Posted March 20, 2009 Share Posted March 20, 2009 <?php $text = 'Hello: 5 Goodbye: 3'; $text = preg_replace('/(Hello\:\s+)(\d+)/e','"$1".($2+1)',$text); print $text; ?> Link to comment https://forums.phpfreaks.com/topic/150315-edit-text-file/#findComment-789426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.