Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello please guide me

how to get the value ["text"]=>
string(4) "head"
to the php variable

from the below json


thanks in advance
HTML
array(6) {
  ["result"]=>
  string(2) "ok"
  ["tuc"]=>
  array(30) {
    [0]=>
    array(4) {
      ["phrase"]=>
      array(2) {
        ["text"]=>
        string(4) "head"
        ["language"]=>
        string(2) "en"
      }
Posted
Updated 7-Jan-16 21:04pm
v2
Comments
Mohibur Rashid 8-Jan-16 1:53am    
try this code and try to figure out, how it would work
<pre>
<?php
$ls["a"]="it";
$ls["b"]="is";
$ls["c"]="friday";

$ds=json_encode($ls);


echo $ds;
echo "\n";

$ps=json_decode($ds);

print_r($ps);

</pre>
Member 11811139 8-Jan-16 2:22am    
i am beginner can you make the code for my question please
Mohibur Rashid 8-Jan-16 3:12am    
The one in the mentioned "below" is not json. that output is created by print_r function, I guess. If you are a noob, I would suggest learn this issue separately
1. array in php
2. accessing array with php. I would suggest to take a look at foreach function
3. json structure
4. json_decode function in php
5. json_encode function in php

php array and json might look alike, to you, but they are not same thing. So, the "below json" is not json. This is an example of JSON :
{"a":"it","b":"is","c":"really","d":"friday"}

I feel like you are looking for alternative of Studying. I would say, its a bad practice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900