提取数组中的值并创建变量php [英] extract values in array and create variable php
本文介绍了提取数组中的值并创建变量php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Stackoverflow和程序员!
Hi Stackoverflow and programmer!
我有此代码:
$result = print_r($reponse, true);
echo $result;
请给我这个输出:
Array ( [333212] => Array ( [view] => 323 [sold] => 3 [buy] => 43 [number] => 333212 ) )
我需要找到一种类似的方法:
I need to find a way to have something like :
echo $variable['view']; (323)
echo $variable['buy']; (3)
echo $variable['sold']; (43)
我检查并尝试了很多方法,例如extract();.连载();dumb_var,我尝试explode("),我到处搜索了一下,但是却找不到答案.
I check and try a lot of things like extract(); serialize(); dumb_var i try explode("") i search a little everywhere but dint find answer.
非常感谢您的帮助!非常感激!!!
Thanks a lot for the help ! much apreciated !!!
Pierre-luc
Pierre-luc
推荐答案
您正在使用多数组
<?php
$response = Array ( "333212" => Array ( "view" => 323, "sold" => 3, "buy" => 43, "number" => 333212 ) ) ;
$variable = $response["333212"];
echo $variable['view']."\n";
echo $variable['buy']."\n";
echo $variable['sold'];
?>
这篇关于提取数组中的值并创建变量php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文