php - how to get single value from array by key
Get the solution ↓↓↓Solution:
PHP
can't read json objects, you first need to convert it to aPHP
array.
You can usejson_decode()
to do that.
Then you can access the values using the key"Technology"
.
$table = '{}'; // your json object in string format
$table = json_decode($table, true); // decode the json string to PHP array
echo $table['Technology']; // show the Technology value
You can then also loop through your object using this:
foreach($table as $value){
echo $value."<br/>";
}
// this will show all results on a new line
Answer
Solution:
Here is an example.
$array =json_decode('{"Technology": "GSM \/ HSPA \/ LTE"}');
$json_array =($array);
$values = $json_array->Technology;
//echo $values;
$text = explode("/", $values);
var_dump( $text);
Output: array(3) { [0]=> string(4) "GSM " [1]=> string(6) " HSPA " [2]=> string(4) " LTE" }
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: you must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.