How to create a nested array out of an array in PHP

前端 未结 5 1840
悲&欢浪女
悲&欢浪女 2020-12-06 21:17

Say, we have an array: array(1,2,3,4,...) And I want to convert it to:

array(
    1=>array(
        2=>array(
            3=>array(
           


        
5条回答
  •  失恋的感觉
    2020-12-06 21:42

    I think the syntax for the multidimensional array you want to create would look like the following.

    $array = array(
    
       'array1' => array('value' => 'another_value'), 
       'array2' => array('something', 'something else'),
       'array3' => array('value', 'value')
    );
    

    Is this what you're looking for?

提交回复
热议问题