Friday, 15 July 2011

php - Replacing text between two limts -



php - Replacing text between two limts -

i have been trying text between 2 symbols replaced preg_replace, alas still not quite getting right null output empty string, have far

$start = '["'; $end = '"]'; $msg = preg_replace('#('.$start.')(.*)('.$end.')#si', '$1 test $3', $row['body']);

so illustration output looking be:

normal text [everythingheregone] after text

to

normal text [test] after text

you defining $start , $end arrays, using normal variables. seek changing code this:

$start = '\['; $end = '\]'; $msg = preg_replace('#('.$start.')(.*)('.$end.')#si', '$1 test $3', $row['body']);

php regex

No comments:

Post a Comment