Php array (1) & lt ;? Php initialization creation method $ stu1 [name] binghui; $ stu1 [sex] Male; $ stu1 [age] 20; print_r ($ stu1); * Array ([name] & gt; binghui [sex] & gt; male [age] & gt; 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) */?>