2012-10-24 78 views
-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] => [email protected] [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))) 

我怎樣才能得到一個值

回答

1
foreach $post as $sub { 
    foreach $sub as $single { 
     echo $single; 
    } 
} 
2

強制轉換它陣列?

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

然後你就可以通過它循環通過正常的陣列

foreach ($arr as $key => $value){....} 
1

認爲你應該學習的arraysobjects第一的基礎知識。 無論如何,以獲得可以說subscriber_id你應該使用以下值:

$post[0][0]->subscriber_id 

首先你進入數組,然後獲得價值了對象的