Jump to content

echo strinf from inside variable


jmyeom

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.