一键推送多个元素
Push multiple elements in one key
foreach ($hash as $h) {
array_push($users, $h['entities']['urls'][0]['expanded_url']);
}
我还想将 $h['created_at']
推入 $users
,所以它看起来像这样:
Array
(
[0] => Array
(
[0] => 'http://www.google.com'
[1] => 'Sun May 17 06:32:14 +0000 2015'
)
)
有什么办法可以做到吗?
最简单的方法是这样的:
$user[] = $h['created_at'];
如果我没理解错的话,你想要数组的数组
foreach ($hash as $h)
$users[] = array($h['entities']['urls'][0]['expanded_url'], $h['created_at'] );
foreach ($hash as $h) {
array_push($users, $h['entities']['urls'][0]['expanded_url']);
}
我还想将 $h['created_at']
推入 $users
,所以它看起来像这样:
Array
(
[0] => Array
(
[0] => 'http://www.google.com'
[1] => 'Sun May 17 06:32:14 +0000 2015'
)
)
有什么办法可以做到吗?
最简单的方法是这样的:
$user[] = $h['created_at'];
如果我没理解错的话,你想要数组的数组
foreach ($hash as $h)
$users[] = array($h['entities']['urls'][0]['expanded_url'], $h['created_at'] );