Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

strreplace

Array (     [my_textarea] => HELLO )

str replace
only want 'HELLO'

 
Avatar of john-formby
john-formby
Flag of Ghana image

Do you mean echoing out the value to the page?

If so, just echo like this:

<?php
$myarray = Array(my_textarea => 'HELLO');
echo $myarray['my_textarea'];
?>

Hope this helps,

John
Avatar of rgb192

ASKER

that is not working

is there a way to do it with a str_replace
What you have there is not a string, but the result of print_r I am guessing?

If that is the case, you cannot simply use str_replace because it is not a string.

Please post your code and I will assist further
Avatar of rgb192

ASKER

it is not the result of print_r


$variable='Array (     [my_textarea] => HELLO )';
echo $varible



ASKER CERTIFIED SOLUTION
Avatar of Rok-Kralj
Rok-Kralj
Flag of Slovenia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of derdiusz
derdiusz

Try to use eval() method:

$data = 'Array (     my_textarea => HELLO )';

eval("\$arr = $data;"); // remember to use ";" at the end (after $data)

And from now in variable $arr you've got your array. If want your "HELLO" use:

echo $arr['my_textarea'];


Greetings!
Yes, along with a bunch of errors.
Only twice Noticy ;)

but when you add:

$data = 'Array (     [my_textarea] => HELLO )';
$data = strreplace(array('[', ']'), array("['", "']"), $data);

it be nicer, a little ;)
Avatar of rgb192

ASKER

thanks