Hi, Lets say I have an array of names like this... $names['john'] = 'John Fisher'; $names['frank'] = 'Frank Jones'; $names['dave'] = 'Dave Williams'; $names['adam'] = 'Adam King'; PHP: I then had a string, like this... $string = 'Johns full name is <tag name="john"/>.<br/> Franks full name is <tag name="frank"/>'; PHP: That should result in this... I basically want to replace the <tag> element with the persons full name. It is the 'name' attribute that specifies which name to use from the array. I know str_replace will do this, but I can't figure out how. Thanks!
$output = preg_replace("#\<tag.+name\=[\"|\'](.+)[\"|\'].*\>.*\<\/tag\>#U","{tag_$1}",$output); PHP: I then looped through the array of names are replaced {tag_x} using str_replace from the array.