Change an associative array into an indexed array / get an Zend_Table_Row_Abstract as non-associative

后端 未结 4 1394
无人及你
无人及你 2021-02-03 17:19

Hi out there in Stackland. I was wondering if there was either a function or an easy way to change an associative array into an indexed array.

To elaborate, I\'m using

4条回答
  •  粉色の甜心
    2021-02-03 17:48

    for multi layered array i use this:


    function getIndexedArray($array) {
            $arrayTemp = array();
            for ($i=0; $i < count($array); $i++) { 
                $keys = array_keys($array[$i]);
                $innerArrayTemp = array();
                for ($j=0; $j < count($keys); $j++) { 
    
                    $innerArrayTemp[$j] = $array[$i][$keys[$j]];                
                }
                array_push($arrayTemp, $innerArrayTemp);
            }
            return $arrayTemp;
        }
    

    it turns this:

    (
        [0] => Array
            (
              [OEM] => SG
                [MODEL] => Watch Active2
                [TASK_ID] => 8
                [DEPT_ASSIGNED] => Purchashing  
            )
    )
    

    into this :

    [0] => Array
            (
              [0] => SG
                [1] => Watch Active2
                [2] => 8
                [3] => Purchashing  
            )
    

提交回复
热议问题