PHP Learning Array--Create array "1"

Source: Internet
Author: User

There are three ways to define arrays in PHP, namely:

<? PHP     // The first method is created with the    keyword array. $username Array ("Demo1", "Demo2", "Demo3", "Demo4");    
<? PHP     // The second method is to create an array by declaring a variable directly, adding brackets to the right of the variable    $usrename Array ();     $username [0]= "AAA";     $username [1]= "BBB";     $username [2]= "CCC";         Print_r ($username);
<?PHP/*Range () Prototype: * Array range (mixed $start, mixed $limit [, number $step = 1]) * Parameter Description: * First value of start sequence                。                The limit sequence ends at the value of limit. Step if you give the step value, it will be used as the step value between the units. Step should be positive.         If not specified, step defaults to 1. * Manual Description: * range-Create an array containing the specified range of cells **///the third way to create this is to use a function (range) to create the array$number=Range(0, 10);//creates an array of numbers//print_r ($number);/*results * Array ([0] = 0 [1] = 1 [2] = 2 [3] = 3 [4] = 4 [5] = 5 [6] = 6 [7] = 7 [8] => ; 8 [9] = 9 [ten] = ten)*///We can also specify his stride size for this set of arrays created .$number=Range(0, 10,2);//create an array of a set of numbersPrint_r($number);/*results * Array ([0] = 0 [1] = 2 [2] = 4 [3] = + 6 [4] = 8 [5] = +)*///You can also create a set of alphabetic arrays:$eng=Range(' A ', ' Z ');Print_r($eng);/*results * Array ([0] = a [1] = b [2] = + c [3] + d [4] = e [5] + f [6] = g [7] = h [8] => ;  I [9] = J [Ten] + k [one] = l [+] = m [+] = n [+] = o [+] = p [+] = q [+] = R [18] + s [+]-t [+] = u [x] = v [x] = w [+] + × [+] = y [ +] = z)*/

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.