在数组操作中需要帮助(php) [英] Need help in array manipulation (php)

查看:71
本文介绍了在数组操作中需要帮助(php)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个$ record数组

I have this $record array

array(4) { 
[0]=> array(2) { ["ROLE_ID"]=> string(1) "2" ["SUBFUNCTION_ID"]=> string(3) "904" } 
[1]=> array(2) { ["ROLE_ID"]=> string(1) "2" ["SUBFUNCTION_ID"]=> string(3) "903" } 
[2]=> array(2) { ["ROLE_ID"]=> string(1) "2" ["SUBFUNCTION_ID"]=> string(3) "902" } 
[3]=> array(2) { ["ROLE_ID"]=> string(1) "2" ["SUBFUNCTION_ID"]=> string(3) "901" } 
} 

我该如何操纵它,使其变得像这样?

How can i manipulate it so it will become like this?

array("901","902","903","904");

预先感谢

推荐答案

$subfunctionIds = array();

foreach($record as $values) {
   $subFunctionIds[] = $values['SUBFUNCTION_ID'];
}

// If you want them reversed like in your example output...
$subFunctionIds = array_reverse($subFunctionIds);

var_dump($subFunctionIds);

这篇关于在数组操作中需要帮助(php)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆