seaten Posted March 2, 2006 Share Posted March 2, 2006 Hi guys,I'm trying to replace a stringA with stringB(this has a variable in it)$theData = ereg_replace('<b>', '<b> $person_name', $theData);echo $theData;The problem is : '<b> $person_name'The value of $person_name is not displayed, so what do I need to add to display the value of the variabe ?Regards and thanks in advance Quote Link to comment Share on other sites More sharing options...
dcro2 Posted March 2, 2006 Share Posted March 2, 2006 Hi there,In order for PHP to parse (add the actual value of the var) you need double quotes around it:$theData = ereg_replace('<b>', "<b> $person_name", $theData);echo $theData;OR:$theData = ereg_replace('<b>', '<b> '.$person_name, $theData);echo $theData; Quote Link to comment Share on other sites More sharing options...
seaten Posted March 2, 2006 Author Share Posted March 2, 2006 [!--quoteo(post=351046:date=Mar 2 2006, 01:47 PM:name=dcro2)--][div class=\'quotetop\']QUOTE(dcro2 @ Mar 2 2006, 01:47 PM) [snapback]351046[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi there,In order for PHP to parse (add the actual value of the var) you need double quotes around it:$theData = ereg_replace('<b>', "<b> $person_name", $theData);echo $theData;OR:$theData = ereg_replace('<b>', '<b> '.$person_name, $theData);echo $theData;[/quote]thanks a million Quote Link to comment Share on other sites More sharing options...
khburres Posted March 2, 2006 Share Posted March 2, 2006 Slight alteration from:$theData = ereg_replace('<b>', '<b> $person_name', $theData);to:$theData = ereg_replace('<b>', '<b> ' . $person_name, $theData);Example:[code]<?php$person_name = "Billy";$theData = "<b> is great";$theData = ereg_replace('<b>', '<b> ' . $person_name, $theData);echo $theData;?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.