Php array (1)

Source: Internet
Author: User
Php array (1) & lt ;? Php // ==== initialization creation method ======/// $ stu1 ['name'] = 'binghui '; $ stu1 ['sex'] = 'male'; $ stu1 ['age'] = '20'; print_r ($ stu1);/* Array (fun php Array (1)
 Binghui [sex] => male [age] => 20) * // initialization method for easy running, temporarily add a unit $ stu1 ['height'] = '000000'; print_r ($ stu1 ); /* Array ([name] => binghui [sex] => male [age] => 20 [height] => 170) * /// === array structure to create =====// $ stu1 = array ('name' => 'binghui ', 'Sex' => 'male', 'age' => '20'); print_r ($ stu1 ); /* result Array ([name] => binghui [sex] => male [age] => 20) */?>
 Mei [1] => Lan [2] => Zhu [3] => Chrysanthemum) * // the array created by the careless person $ stu ['student id '] = 234; $ stu ['name'] = 'Lee 3'; $ stu [] = 174; $ stu ['Year'] = '2's 2'; $ stu [] = 'hengshui '; print_r ($ stu);/* result: array ([student ID] => 234 [name] => Li San [0] => 174 [grade] => sophomore year [1] => Hengshui) * // *** if the square brackets are provided but the key name is not specified, the current maximum integer index value is used. the new key name is the value + 1. // The preceding example starts from 5 + 1. if no integer index exists, the key name is 0. // In $ yan, the value is overwritten if the specified key name already has a value. (See the following example) ***/$ butty [] = 'Lin Zhiling '; // key = 0 $ butty [] = 'silo Kong '; // key = 1 $ butty [1] = 'burwlands '; // specify key = unit 1; value: burwlands, in fact, this is to change the content of Cabinet 1 to "Wu tenglan" $ butty [3] = 'Ze xxx'; print_r ($ butty ); /* Array ([0] => Lin Zhiling [1] => Wu tenglan [3] => Xiao zexxx) * // the preceding three examples, discuss the growth relationship of keys. $ arr = array ('中', 'hua', 'min', 'guo'); // 0 1 2 3 print_r ($ arr ); unset ($ arr [3]); print_r ($ arr); $ arr [] = 'clan '; print_r ($ arr); // The key is: 0124, if a unit is deleted, the growth of the key is not affected and continues to grow. /* Array ([ 0] => China [2] => China [3] => China) array ([0] => medium [1] => Hua [2] => min) array ([0] => medium [1] => Hua [2] => min [4] => family) */?>



 

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.