preg_replace help - ignore spaces and tabs
Posted on 2008-06-17
I want to parse a PHP config file and replace certain defines.
So if I have an array like the following and want to read the file and replace the define for 'most_viewed'. I could do a preg_replace on that line and re-write the file. I need a preg_replace that will update that one line searching on 'most_viewed' + (n number of spaces or tabs) + '==>' + (n number of spaces or tabs) and replace it with the same formatting except with my new 'string here'.
$LANG_MGE01 = array (
'featured_series' => 'Featured Series',
'featured_episodes' => 'Featured Episodes',
'featured' => 'Featured',
'most_viewed' => 'Most Viewed',
'most_discussed' => 'Most Discussed',
'most_recent' => 'Most Recent'
Can that be done with a preg_replace where the search string match is saved as an argument and then used in the replace so the line formatting is preserved.