Home > php教程 > php手册 > php函数:实现从二维数组对象返回一维数组

php函数:实现从二维数组对象返回一维数组

WBOY
Release: 2016-06-13 10:38:42
Original
1240 people have browsed it

function getOneDimArray($arr,$value,$key="id"){
        $array = array();
        if(is_array($arr) && !empty($arr)){
                foreach($arr as $k=>$val){
                        $array[$val->$key] = $val->$value;
                }
                return $array;
        }else return $arr;
}


?>

  • 来源: 编程之家
  • source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template