-3

当我打印数组 print_r($post); 时得到了这个结果

Array ( [0] => Array ( [0] => stdClass Object ( [subscriber_id] => 80010055 [cto_id] => [name] => n [mobile] => 1234564444 [state] => [city] => fsd [cto_subscriber_id] => 0 [password] => e10adc3949ba59abbe56e057f20f883e [email] => n@n.com [email_verified] => 1 [ip_address] => ::1 [last_login_time] => 2012-10-24 11:37:19 ) ) [1] => Array ( [0] => stdClass Object ( [subscriber_id] => 80010055 [ip_address] => [landline_number] => [sex] => 0 [dob] => 0000-00-00 00:00:00 [marital_status] => hfg [state] => [addres] => fgh [city] => fghfg [pincode] => fghfgh ) ) ) 

如何获得单个值

4

3 回答 3

2

将其类型转换为数组?

$arr = (array)$post[0][0];

然后你就可以像通过普通数组一样循环遍历它

foreach ($arr as $key => $value){....}
于 2012-10-24T09:43:28.170 回答
1
foreach $post as $sub {
    foreach $sub as $single {
        echo $single;
    }
}
于 2012-10-24T09:43:21.770 回答
1

认为您应该首先学习数组对象的基础知识。无论如何,为了获得让我们说subscriber_id的值,您应该使用以下内容:

$post[0][0]->subscriber_id

首先你进入数组,然后从 Object 中取出值

于 2012-10-24T09:48:20.710 回答