Play the PHP array (1)

Source: Internet
Author: User
Play PHP Array (i)
 
  Binghui    [Sex] = male    [age] + 20) *///initialization mode, easy to run, temporarily add a unit $stu1[' height ']= ';p rint_r ($stu 1);/*array (    [Name] = Binghui    [Sex] = [age] = [    height] = +] *///===array structure to create =====//$stu 1=array (' name ' = ' Binghui ', ' Sex ' = ' ' male ', ' age ' = ' + ');p Rint_r ($stu 1);/* result Array (    [name] + Binghui    [sex] + male    [age] = = */?>)
  Mei [1] = [2] [+] = [3] = [$stu[] = [+] [[] =] [[' Grade '] = ' 174 ', ' *///'] = [' School number '] = 234; Sophomore '; $stu [] = ' Hengshui ';p rint_r ($STU);/* Result: Array ([student] = 234 [name] = Lie triple [0] = 174 [Grade] = sophomore [1] =& Gt Hengshui) *//*** If the square brackets are given but no key name is specified, the current maximum integer index value is taken, and the new key name is the value + 1. The previous example starts with 5+1 If no integer index is currently present, the key name is 0. In $yan if the specified key name already has a value, the value will be overwritten.  (see example below) ***/$butty [] = ' Lin Chi-ling ';  Key = 0 $butty [] = ' Cang jing empty '; Key = 1 $butty [1] = ' Enrique '; Indicate key = 1 unit, value is Enrique, this is actually again the contents of the 1th cabinet modified to "Enrique" $butty [3] = ' Ozawa xxx '; Print_r ($butty); /*array ([0] = Lin Chi-ling [1] = enrique [3] = Ozawa xxx) *///above these 3 examples, discusses the relationship between the growth of a clear key. $arr = Array (' Medium ', ' China ', ' people ', ' country '); 0 1 2 3 print_r ($arr); Unset ($arr [3]); Print_r ($arr); $arr [] = ' family '; Print_r ($arr); The key is: 0124, delete a unit, the growth of the key is not affected by this effect, continue to increase./*array ([0] = [1] = [2] [+] [3] = = Country) Array ([0] =&G T



  • 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.