Traversal of PHP------arrays

Source: Internet
Author: User

Echo current ($attr); Takes the value of the current element

echo Key ($ATTR); Takes the key of the current element

Next ($ATTR); Point the pointer inside the array to the next (Move Down)
Prev ($attr); Point the pointer inside the array to the previous (move up)

End ($ATTR); Point the pointer to the last
Reset ($attr); Reset the pointer

/*while (Next ($attr))
{
Echo current ($attr). " <br> ";
}*/

/*do
{
Echo current ($attr). " <br> ";
}
while (Next ($attr)) */

Global variables
/* $a = 10;

function Show ()
{
$a = 8;

Global $a;

echo $a;
}
Show (); */

//var_dump ($_server);
//var_dump ($_env);
$_post//POST Value submitted $_get//Submit GET value $_request// The Get or Post value submitted
$_files User-submitted file information
//var_dump ($_files);


echo count ($attr); Gets the number of array elements
var_dump (In_array ("Aaaac ", $attr)); Determines whether the element is inside an array
$attr = Array_reverse ($ attr); Flip array
$attr = Array_unique ($attr); The elements of the array are de-weighed
unset ($attr ["]");// Delete an element inside an array

$attr = Array (1,2,3,4,5,6);
$attr 1 = array (9,10);
Unset ($attr [2]);
$attr = Array_values ($attr); Re-establish Index
$attr = Array_merge ($attr, $attr 1); Merging arrays

Adding elements to an array
Array_push ($attr, 10); Append, Function Way
$attr [] = 10; How to assign a value



Traversal of PHP------arrays

Related Article

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.