Jump to content

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.