0

I got the following code is there anyway to work with that like an array?

$var = 
"{"uid":"cb463625fc9dde2d82207e15bde1b674513094011b2976.06073807","name":"marius"}{"uid":"2393d7a6a3258894acc34581978453fa513094011b2ab8.28630478","name":"buenyamin"}";

to print it out like

echo $var[0].uid."<br>";
echo $var[1].uid;
0

2 Answers 2

1

Try this :

$array = json_decode($var,true);

echo "<pre>";    
print_r($array);

NOTE : the second parameter true in json_decode is needed to get the out put as array, else the output will be object

ref: http://php.net/manual/en/function.json-decode.php

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

Comments

1

Use json_decode to decode a string into a PHP array.

$var = 
"{"uid":"cb463625fc9dde2d82207e15bde1b674513094011b2976.06073807","name":"marius"}{"uid":"2393d7a6a3258894acc34581978453fa513094011b2ab8.28630478","name":"buenyamin"}";
echo '<pre>' . print_r(json_code($var, true)) . '</pre>';

Comments

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.