Convert array into simple 1 level array in PHP

后端 未结 4 752
遇见更好的自我
遇见更好的自我 2021-01-14 20:16

A simple thing to do, but I forgot how to convert

Array
(
    [0] => Array
        (
            [hashcode] => 952316176c1266c7ef1674e790375419
                


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 21:01

    A good ol' loop solves :)

     'hash' ),  
        array( 'hashcode' => 'hash2' ), 
    );
    
    $flat = array();
    
    foreach ( $array as $arr ) {
        $flat[] = $arr['hashcode'];
    }
    
    echo "
    ";
    
    print_r( $flat );
    
    ?>
    

提交回复
热议问题