All about Array in PHP

1. Array creation

  • using array() built in function for creating array in php code.

$a = array (
‘l’ => 10,
‘11’ => “test”,
‘another element’
var_dump ($a);

array(3) {
string(4) “test”
string(15) “another element”

2. Using the array operator

  • The array operator [ ] is used to address an element of a particular array. For example,

3. Counting the number of elements in an array
4. Assigning values to multiple variables from an array

  • using the list() function
  • advantages and disadvantages of list() function

5.   Multi dimensional array
6.   Navigation arrays

  • Using for loop by counting the numbers of elements in an array
  • using foreach iteration
  • Advantages and dis advantages
  • using the internal Pointer
  • using a callback function

7. Manipulating array keys


  • checking if an element exists
  • changing the arrays of keys
  • sorting an array by its keys
  • sorting parameter for sorting functions

8. Manipulating arrays


9. Sorting multidimensional arrays


10. Random and shuffle array

shuffle(), array_rand()

11. Merging arrays


12. Intersection and difference


13. Serializing arrays


About Mazharul Anwar

A PHP and javascript nerd believe in web applications and open source goodness. Ex MS Windows user converted to linux fanboy and love gadgets. Coding in python and maintaining servers become my passion. Website performance and optimization geek.
This entry was posted in Programming and tagged , , . Bookmark the permalink.

One Response to All about Array in PHP

  1. what a great site and informative posts, I will add a backlink and bookmark your site. Keep up the good work!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s