PHP Array Introduction


Function Description PHP


 Testing Array and sizeof( )
<?php
$fixture = Array( );
// $fixture is expected to be empty.

$fixture[] = "element";
// $fixture is expected to contain one element.
?>


A really simple way to check whether we are getting the results we expect is to print the result of sizeof( ) before and after adding the element

array() Creates an array 
array_change_key_case() Returns an array with all keys in lowercase or uppercase
array_chunk() Splits an array into chunks of arrays 
array_combine() Creates an array by using one array for keys and another for its values 
array_count_values() Returns an array with the number of occurrences for each value
array_diff() Compares array values, and returns the differences
array_diff_assoc() Compares array keys and values, and returns the differences 
array_diff_key() Compares array keys, and returns the differences 
array_diff_uassoc() Compares array keys and values, with an additional user-made function check, and returns the differences 
array_diff_ukey() Compares array keys, with an additional user-made function check, and returns the differences 
array_fill() Fills an array with values 
array_filter() Filters elements of an array using a user-made function 
array_flip() Exchanges all keys with their associated values in an array 
array_intersect() Compares array values, and returns the matches 
array_intersect_assoc() Compares array keys and values, and returns the matches 
array_intersect_key() Compares array keys, and returns the matches 
array_intersect_uassoc() Compares array keys and values, with an additional user-made function check, and returns the matches 
array_intersect_ukey() Compares array keys, with an additional user-made function check, and returns the matches 
array_key_exists() Checks if the specified key exists in the array 
array_keys() Returns all the keys of an array 
array_map() Sends each value of an array to a user-made function, which returns new values 4
array_merge() Merges one or more arrays into one array 
array_merge_recursive() Merges one or more arrays into one array 
array_multisort() Sorts multiple or multi-dimensional arrays 
array_pad() Inserts a specified number of items, with a specified value, to an array 
array_pop() Deletes the last element of an array 
array_product() Calculates the product of the values in an array 
array_push() Inserts one or more elements to the end of an array 
array_rand() Returns one or more random keys from an array 
array_reduce() Returns an array as a string, using a user-defined function 
array_reverse() Returns an array in the reverse order 
array_search() Searches an array for a given value and returns the key 
array_shift() Removes the first element from an array, and returns the value of the removed element 
array_slice() Returns selected parts of an array 
array_splice() Removes and replaces specified elements of an array 
array_sum() Returns the sum of the values in an array 
array_udiff() Compares array values in a user-made function and returns an array 
array_udiff_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 
array_udiff_uassoc() Compares array keys and array values in user-made functions, and returns an array 
array_uintersect() Compares array values in a user-made function and returns an array 
array_uintersect_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 
array_uintersect_uassoc() Compares array keys and array values in user-made functions, and returns an array 
array_unique() Removes duplicate values from an array 
array_unshift() Adds one or more elements to the beginning of an array 
array_values() Returns all the values of an array 
array_walk() Applies a user function to every member of an array 
array_walk_recursive() Applies a user function recursively to every member of an array 
arsort() Sorts an array in reverse order and maintain index association 
asort() Sorts an array and maintain index association 
compact() Create array containing variables and their values
count() Counts elements in an array, or properties in an object 
current() Returns the current element in an array 
each() Returns the current key and value pair from an array 
end() Sets the internal pointer of an array to its last element 
extract() Imports variables into the current symbol table from an array 
in_array() Checks if a specified value exists in an array
key() Fetches a key from an array
krsort() Sorts an array by key in reverse order
ksort() Sorts an array by key 
list() Assigns variables as if they were an array 
natcasesort() Sorts an array using a case insensitive "natural order" algorithm 

natsort() Sorts an array using a "natural order" algorithm 
next() Advance the internal array pointer of an array 
pos() Alias of current() 
prev() Rewinds the internal array pointer 
range() Creates an array containing a range of elements 
reset() Sets the internal pointer of an array to its first element
rsort() Sorts an array in reverse order
shuffle() Shuffles an array 
sizeof() Alias of count()
sort() Sorts an array 
uasort() Sorts an array with a user-defined function and maintain index association
uksort() Sorts an array by keys using a user-defined function
usort() Sorts an array by values using a user-defined function 

Related Posts:
  • How to Enable mod_rewrite at Server mod_rewrite may not be enabled by default in your Apache configuration. To make sure,open the Apache configuration file, named httpd.conf. The full path of the file will be \Program Files\xampp\apache\conf\httpd.conf. Open … Read More
  • how Installing mod_rewrite localhost If you’ve installed Apache yourself, read on. Because of its  popularity, mod_rewrite is now included with all common  Apache distributions. If desired, you can verify if your Apache installation has the mod_rewr… Read More
  • PHP while Loop PHP while Loop with code while - loops run  a set of code as  the  condition is true. Basic Syntaxwhile (condition){    code for executed;}<?php$k=1;while($k<=5) {  echo "The numbe… Read More
  • codeigniter routes page The  routes.php filelets you remap URI requests to specific controller functions. For example, you may have a controller named sitewith a function named index. The URI for this controller/function combination might be… Read More
  • Sorting Arrays-PHP PHP supports a variety of ways to sort an array when  I say sort, I am referring to an alphabetical sort if it is a string,  and a numerical sort if it is a number. When sorting an array,  you must k… Read More
  • PHP Expressions An expression is the basic building block of the language.  Anything with a value can be thought of as an expression.  Examples include: 5 5+5 $a $a==5 sqrt(9) By combining many of these basic expressions, you… Read More
  • php-Dynamic Variables Sometimes it is useful to set and use variables dynamically.  Normally, you assign a variable like this:  $var = "hello";   Now let's say you want a variable whose name is the  value of the $var va… Read More
  • what is CodeIgniter Helpers? Helpers, as their name implies, help you with specific tasks. Unlike libraries, helpers are not object -oriented but procedural in nature. Each helper contains one or more functions, each focusing on a specific task, with ze… Read More
  • URL rewriting-various exercises-seo  Installing mod_rewrite Testing mod_rewrite Working with regular expressions Rewriting numeric URLs with two parameters Rewriting keyword-rich URLs Building a link factory Pagination and UR… Read More
  • security to POST-PHP $_POST  POST-method variables. Form field data from regular  POST-method forms.   PHP automatically creates variables for all the data it receives  in an HTTP request. This can include GET data, POST … Read More
  • Visualize Traffic with DIY Vector you will learn how to create your own traffic chart using the incredibly cool Canvas framework, which can produce vector graphics and animations with a little bit of HTML and JavaScript. All code referenced in this hack i… Read More
  • var_dump and print_r -PHP-standard Functions like var_dump and print_r are also invaluable when debugging var_dump var_dump functions displays information about variables in a simple, readable  format. This function is very useful when debugging—p… Read More
  • PHP-MySQL application Security With these two methods, there’s no longer any need to ever use GET for requests internal to an application. You may still need it for external requests, to other applications and web sites that aren’t coded to look for their… Read More
  • Building Dynamic Images-PHP You want to create an image based on a existing image template and dynamic data typically text). For instance, you want to create a hit counter. Load the template image, find the correct position to properly cente… Read More
  • MySQL with php The basic steps of performing a query, whether using the mysql command-line tool or PHP, are the same:Connect to the database.Select the database to use.Build a SELECT statement.Perform the query.Display the results. Wh… Read More