Which method can be used to change the first subscript of the array, and dump () is used to print the new subscript. The code is as follows:-php Tutorial

Source: Internet
Author: User
Which method can be used to change the first subscript of the array, and dump () is used to print the new subscript. The code is as follows: PHPcodearray (1 & gt; array (0 & gt; array (created & gt; integer1332383287updated & gt; how can I change the first subscript of an array, dump () is used to print the new subscript. The code is as follows:
PHP code
  Array (1 => array (0 => array ('created '=> integer 1332383287 'updated' => integer 1332385146 'id' => string '30' (length = 2) 'level' => integer 10' tag _ id' => integer 1 'status' => integer 0 'creator _ uid' => integer 6 'assign _ uid' => integer 6 'assign _ history '=> string' | 6 | 6 | 6 |' (length = 8) 'title' => string' [iBay365] '(length = 10) 'context' => string '))) // The requirement is "1 => array (0 => array (......)) "Here 1 is changed to php, ajax, and other text, and then again with dump () print it out // it becomes "php => array (0 => array (......)) "How can I do this? I couldn't think of it for a long time, and I checked the manual. // It seems that there is no such function. thank you for your help.


------ Solution --------------------
Delete and merge the functions. maybe there are no functions that directly implement this function.

PHP code
// $ Key = ......; $ Arr = array_merge (array ($ key => array_shift ($ arr), $ arr );
------ Solution --------------------
For.
------ Solution --------------------
Rebuild an array.
------ Solution --------------------
PHP code
$ Ar1 = array (1 => array ('20160901'), 6 => array ('20160901'), 2 => array ('20160901 ')); $ ar2 = array ('php', 'Ajax ', 'mysql'); $ ar2 = array_combine ($ ar2, array_values ($ ar1); echo'
'; Print_r ($ ar2 );
------ Solution --------------------
PHP code
[[email protected] csdn]$ php exchange.php Array(    [PHP] => Array        (            [0] => index 1        )    [AJAX] => Array        (            [0] => index 6        )    [MySQL] => Array        (            [0] => index 2        ))[[email protected] csdn]$ cat exchange.php 
        array(                                        "index 1"                                ),                        6 => array(                                        "index 6"                                ),                        2 => array(                                        "index 2"                                )                );$arr2 = array(                        'PHP' => array(),                         'AJAX' => array(),                        'MySQL' => array()                );$arr2 = array_combine(array_keys($arr2), array_values($arr1));print_r($arr2);?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.