-1

I have this:

$rm = json_decode($room_list[0]['room']);

and i want to set a variable $string which include the result of echo of above variable.
For Example, IF:

echo json_decode($room_list[0]['room'];

echos: Lorem Ipsum <a href="www.google.com>GG</a>.

i want the string to be:

$string = 'Lorem Ipsum <a href="www.google.com>GG</a>.'

How can i do that?

10
  • 1
    Your question is unclear. json_encode() returns a value. You can either assign it to a variable, or echo it. Either way, you're assigning or echoing the same thing. Commented Jan 15, 2016 at 23:58
  • 1
    You need a closing ) on your json_decode Commented Jan 15, 2016 at 23:59
  • 1
    Your first line sets a PHP variable to the string. What's wrong with that? Commented Jan 16, 2016 at 0:03
  • 1
    You don't understand what you're talking about. Since you can echo it, it must be a string. What do you think echo is showing? Commented Jan 16, 2016 at 0:06
  • 1
    There's no such thing as "just a variable". A variable is a name for a value, and the type goes with the value. Since json_decode is returning a string, and you assign that to a variable, the variable contains a string. Commented Jan 16, 2016 at 0:07

1 Answer 1

0

It looks like you're trying to do this: how to use JSON.stringify and json_decode() properly

So basically, take stripslashes(htmlspecialchars(JSON_DATA)) from that answer and put $rm = in front :)

Sign up to request clarification or add additional context in comments.

1 Comment

That's the solution! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.