11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 • <strong>PHP</strong> BASICSwww.it-ebooks.info?>}echo "$link";This would result in the following:Online Resources:http://www.apress.comhttp://www.php.<strong>net</strong>http://www.apache.orgThe second variation is well-suited for working with both the key and value of an array. The syntaxfollows:foreach (array_expr as $key => $value) {statement}Revising the previous example, suppose that the $links array contains both a link and acorresponding link title:$links = array("The Apache Web Server" => "www.apache.org","Apress" => "www.apress.com","The <strong>PHP</strong> Scripting Language" => "www.php.<strong>net</strong>");Each array item consists of both a key and a corresponding value. The foreach statement can easilypeel each key/value pair from the array, like this:echo "Online Resources:";foreach($links as $title => $link) {echo "$title";}The result would be that each link is embedded under its respective title, like this:Online Resources:The Apache Web ServerApressThe <strong>PHP</strong> Scripting LanguageThere are other variations on this method of key/value retrieval, all of which are introduced inChapter 5.84

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!