Php array index and key-value Operation TIPS: instance analysis, Operation TIPS: instance Analysis _ PHP Tutorial

Source: Internet
Author: User
Php array indexing and key-value operation skills: instance analysis and operation skills instance analysis. Php array indexing and key-value operation skills example analysis, operation skills example analysis this article describes the php array indexing and key-value operation skills. Share it with you for your reference. The details are as follows: php array indexing and key value operation skills instance analysis, operation skills instance analysis

This article describes the php array indexing and key-value operation skills. Share it with you for your reference. The details are as follows:

<? 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 );? >

I hope this article will help you with php programming.

Examples in this article describe php array indexing and key value operation skills. Share it with you for your reference. Details :...

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.