EvanAgee Posted July 11, 2008 Share Posted July 11, 2008 hey all! Here's what I've got: $value = preg_replace('/#([A-Z])#/',$row[$1."_col"],$value); So #A# would be replaced with the value of $row["A_col"] However, this isn't working and ends up returning nothing. Does anyone have any tips that can help me solve this very frustrating problem? Link to comment https://forums.phpfreaks.com/topic/114325-solved-a-quick-preg_replace-question/ Share on other sites More sharing options...
effigy Posted July 11, 2008 Share Posted July 11, 2008 <pre> <?php $value = '#A#'; $row = array('A_col' => 'ABC'); echo $value = preg_replace('/#([A-Z])#/e', '$row["${1}_col"];', $value); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/114325-solved-a-quick-preg_replace-question/#findComment-587898 Share on other sites More sharing options...
EvanAgee Posted July 11, 2008 Author Share Posted July 11, 2008 <pre> <?php $value = '#A#'; $row = array('A_col' => 'ABC'); echo $value = preg_replace('/#([A-Z])#/e', '$row["${1}_col"];', $value); ?> </pre> You're awesome, thanks so much! Link to comment https://forums.phpfreaks.com/topic/114325-solved-a-quick-preg_replace-question/#findComment-587906 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.