php数组echo out数组对象

时间:2014-11-11 13:58:48

标签: php arrays object

如何从这个数组中回显出“用户名”?

array(2) {
  ["data"]=>
  array(2) {
    [0]=>
    string(14) "username taken"
    [1]=>
    string(20) "email already in use"
  }
  ["error"]=>
  NULL
}

2 个答案:

答案 0 :(得分:1)

试试这个:

//define the array
$array = array("data"=>array("username taken","email already in use"),array("error"=>NULL));
//output full array
var_dump($array);
//output first element of data
echo "<br>".$array["data"][0];

答案 1 :(得分:0)

echo $variableNameOfArray["data"]["0"];

应该做的伎俩。