Getting element from PHP array returned by function

后端 未结 7 1082
野趣味
野趣味 2020-12-11 01:10

I\'m not sure if this is possible, but I can\'t figure out how to do it if it is...

I want to get a specific element out of an array that is returned by a function,

7条回答
  •  独厮守ぢ
    2020-12-11 01:46

    As the others says, there is no direct way to do this, I usually just assign it to a variable like so:

    $items = getSomeArray();
    $item = $items[1];
    
    
    function getSomeArray(){
        $ret = Array();
        $ret[0] = 0;
        $ret[1] = 100;
        return $ret;
    }
    

提交回复
热议问题