Php array indexing and key value Operation Skills

Source: Internet
Author: User
? Php $ arrayarray (a, B, c); defines an array $ array [] Simon; adds a new array element print_r ($ array); Outputs An array ?? Php $ arrayarray (a, B, c); defines an array $ array [9] Simon; adds a new array element print_r ($ array); Outputs An array ?? Create

? Php $ array = array ("a", "B", "c"); // defines an array $ array [] = "Simon "; // Add a new array element print_r ($ array); // output array? ? Php $ array = array ("a", "B", "c"); // defines an array $ array [9] = "Simon "; // Add a new array element print_r ($ array); // output array? ? Php // create

<? Php $ array = array ("a", "B", "c"); // defines an array $ array [] = "Simon "; // Add a new array element print_r ($ array); // output array?>

<? Php $ array = array ("a", "B", "c"); // defines an array $ array [9] = "Simon "; // Add a new array element print_r ($ array); // output array?>

<? Php // create a simple array $ array = array (0 => 1, 1 => 2, 2 => 3, 3 => 4, 6 => 5 ); print_r ($ array); // update the value of 2 in the array to 100 $ array [2] = 100; print_r ($ array ); // Add a key $ array ["X"] = 50; print_r ($ array); // delete all keys now, but keep the structure of the array foreach ($ array as $ I =>$ value) {unset ($ array [$ I]);} print_r ($ array ); // Add another key $ array [] = 25; print_r ($ array); // use the array_values function to re-index $ array = array_values ($ array ); $ array [] = 13; print_r ($ array);?>

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.