a_young_wife's_computerbook (Javascript and PHP)

PHP in_array

in_array: A way to search through an array for a certain match. eg. To check if we have oranges i our array.

Example 1:

<?php
$fruit_list=array ("apple", "orange", "watermelon", "coconut", "strawberry");
if ( in_array ("oranges", $fruit_list))
{
echo "Yes, we have some oranges";
} else
{
echo "We have ran out of oranges and need to order some";
}
?>
Home
Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2011 (1)
    • ▼  March (1)
      • Learning Javascript in 2 days
  • ►  2012 (27)
    • ►  June (27)

Pages

  • Home
  • Javascript Level 1- Basic
  • Javascript Level 2
  • Javascript Level 3-Functions
  • Javascript Level 4
  • Javascript Level 5 - Objects
  • Javascript Level 6 - Math objects
  • Javascript Level 7 - Getting Information from the ...
  • Javascript Level 8 - Interactive buttons and Effec...
  • Useful Computer Learning sites
  • PHP isset( ) vs empty( )
  • PHP is_int( ) and other checking functions
  • PHP or operator
  • PHP elseif
  • PHP switch
  • PHP while vs for
  • PHP arrays
  • PHP in_array
  • PHP key-value pair array
  • PHP other array functions

A Young Wife's links

  • A Young Wife's Computerbook
  • A Young Wife's Cookbook
  • A Young Wife's Notebook
  • A Young Wife's Travelbook
Watermark theme. Powered by Blogger.