Reputation: 922
I have this table row
id | text
1 | {"category_layout":"","image":"images\/icon-48-info.png"}
How can I get only the image path from the text inside the brackets?
What I need is only this: images/icon-48-info.png (Note that there are 2 slashes in the text \ / while I need only one /
EDIT: Actually it is very simple, and I found a nice solution:
$json = $row->text;
$obj = json_decode($json);
echo $obj->{'image'};
No need for regexp or anything else.
Upvotes: 1
Views: 788
Reputation: 37566
Read the string functions reference, try it using the Regexp or Substring_index
Upvotes: 1
Reputation: 922
Actually it is very simple, and I found a nice solution:
$json = $row->text;
$obj = json_decode($json);
echo $obj->{'image'};?>
Upvotes: 0