jmyeom Posted July 16, 2009 Share Posted July 16, 2009 my code does the following: 1 finds "[font= 2 reads the text untill it reachs the first "]" character 3 Reads the data bewteen these 2 points 4, then removes the "[font=" when we searched it before 5 repeats 1+2, but adds one more onto 2... 6 then replaces its compilcated, but it works.. how can i get it to reads a variable that is set inside a function, then echo it? $new1 = str_replace($order1, $order2, $rowb["pagetext"]); function others($f, $g){ global $new1; $before = strstr ($new1, "[font="); if ($before == FALSE) { $newstr1 = $new1; } if ($before == TRUE) { $newstr2 = str_replace("[font=", "", substr(strstr ($new1, "[font="), 0, strpos (strstr ($new1, "[font="), "]"))); $newstring3 = substr(strstr ($new1, "[font="), 0, strpos (strstr ($new1, "[font="), "]")+1); $newstr1 = str_replace($newstring3, $newstr2, $new1); } } others("[font=", "]"); $newstr = $newstr1; Link to comment https://forums.phpfreaks.com/topic/166134-echo-strinf-from-inside-variable/ Share on other sites More sharing options...
MadTechie Posted July 16, 2009 Share Posted July 16, 2009 I'm slightly confused.. do you have some sample data that you use ie convert [font=blar]123[font=blar2] to blar123blar2 EDIT: if the above is what you wanted you could do it like this $data = '[font=blar]123[font=blar2]'; $data = preg_replace('/\[font=([^\]]*)\]/', '\1', $data); echo $data; blar123blar2 Link to comment https://forums.phpfreaks.com/topic/166134-echo-strinf-from-inside-variable/#findComment-876158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.