CODEFETCH™
            Examples
Searched for 1 expression(s): =>  
Source code below from:
Beginning PHP and MySQL 5: From Novice to Professional, Second Edition (Beginning: from Novice to Professional)
By W. Jason Gilmore
Published 23 January, 2006
Average rating

      Powells     Alibris

1590595521/ch13/create_dropdown-2.php (18 lines)
6    $dropdown .= "<option name=\"\">$firstentry</option>"; 
7  
8    foreach($pairs AS $value => $name)
9    { 
10       $dropdown .= ($value == $key) ?  

1590595521/ch13/create_dropdown.php (19 lines)
8  
9       // Create the dropdown elements 
10       foreach($pairs AS $value => $name)
11       { 
12          $dropdown .= "<option name=\"$value\">$name</option>"; 

1590595521/ch14/listing14-9.php (33 lines)
8  
9    $dblogin = array ( 
10       'dsn' => "mysql://corpweb:secret@localhost/corporate",
11       'table' => "userauth",
12       'usernamecol' => "username",
13       'passwordcol' => "pswd",
14       'cryptType' => "md5"
15       'db_fields' => "*"
16    ); 
17  

1590595521/ch20/listing20-11.php (34 lines)
12    // Register the getRandQuote() function.  
13    $server->register("getRandQuote", 
14                 array('format' => 'xsd:string'),
15                 array('return' => 'xsd:string'),
16                 'urn:boxing', 
17                 'urn:boxing#getRandQuote'); 

1590595521/ch20/listing20-6.php (27 lines)
16  
17    // Which parameters should be passed to the doSpellingSuggestion method? 
18    $input = array('phrase' => $keyword, 'key' => $key);
19  
20    // Call the doSpellingSuggestion method 
Source code below from:
Foundation PHP for Dreamweaver 8
By David Powers
Published 19 December, 2005
Average rating

      Powells     Alibris

FdnPHPforDW8/site_check/ch06/navmenu.php (23 lines)
1 <?php 
2 $pages = array('index.php'   => 'Home',
3                'news.php'    => 'News',
4                'blog.php'    => 'Blog',
5                'gallery.php' => 'Gallery',
6                'contact.php' => 'Contact');
7  
8 function insertMenu($pages, $pageID) { 
9   echo "<ul>\n"; 
10   foreach ($pages as $file => $listing) {
11     echo '<li'; 
12     // if the current filename and array key match, insert ID 
Source code below from:
PHP Hacks : Tips & Tools For Creating Dynamic Websites (Hacks)
By Jack Herrington
Published 12 December, 2005
Average rating

      Powells     Alibris

phphacks/amazon/index.php (121 lines)
50       if ( strlen( $product['name'] ) > 0 ) 
51         $out[ $product['asin'] ] = array( 
52           'url' => $product['url'],
53           'imagesmall' => $product['imagesmall'],
54           'name' => $product['name'],
55           'release' => $product['release'],
56           'manufacturer' => $product['manufacturer'],
57           'asin' => $product['asin'],
58           'creator' => $creator,
59           'price' => $price
60         ); 
61     } 

phphacks/breadcrumbs/showpage.php (46 lines)
5  
6 $pages = array( 
7   home => array( id=>"home", parent=>"", title=>"Home", url=>"showpage.php?id=home" ),
8   users => array( id=>"users", parent=>"home", title=>"Users", url=>"showpage.php?id=users" ), 
9   jack => array( id=>"jack", parent=>"users", title=>"Jack", url=>"showpage.php?id=jack" )
10   ); 
11  

phphacks/commaconv/commaconv.php (37 lines)
27       print( ", " ); 
28     print( $fieldnames[ $f ] ); 
29     print( " => " );
30     print( $data ); 
31   } 

phphacks/googleapi/index.php (169 lines)
20  
21 $data = array(); 
22 foreach($google as $key => $result)
23 { 
24   $data []= array( 
25     'title' => $result->title,
26     'snippet' => $result->snippet,
27     'URL' => $result->URL
28   ); 
29 } 

phphacks/googlemap/index.php (66 lines)
1 <?php 
2 $images = array( 
3   array( 'lat' => -121.9033, 'lon' => 37.5029, 'img' => "mp0.jpg" ),
4   array( 'lat' => -121.8949, 'lon' => 37.5050, 'img' => "mp1.jpg" ),
5   array( 'lat' => -121.8889, 'lon' => 37.5060, 'img' => "mp2.jpg" ),
6   array( 'lat' => -121.8855, 'lon' => 37.5076, 'img' => "mp3.jpg" ),
7   array( 'lat' => -121.8835, 'lon' => 37.5115, 'img' => "mp4.jpg" ), 
8   array( 'lat' => -121.8805, 'lon' => 37.5120, 'img' => "mp5.jpg" ) 
Source code below from:
PHP Phrasebook (Developer's Library)
By Christian Wenz
Published 26 September, 2005
Average rating

      Powells     Alibris

ch02-arrays/array_map_recursive.php (19 lines)
9    
10   $a = array( 
11     'harmless' => 
12       array('no', 'problem'),  
13     'harmful' => 
14       array('<bad>', '--> <worse> <<-') 
15   );  

ch02-arrays/each-a.php (7 lines)
1 <?php 
2   $a = array('one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV');
3   while ($element = each($a)) { 
4     echo htmlspecialchars($element['key'] . ': ' . $element['value']) . '<br />';  

ch02-arrays/each-list.php (6 lines)
1 <?php 
2   $a = array('one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV');
3   while (list($key, $value) = each($a)) { 
4     echo htmlspecialchars("$key: $value") . '<br />';  

ch02-arrays/foreach-a.php (6 lines)
1 <?php 
2   $a = array('one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV');
3   foreach ($a as $key => $value) {
4     echo htmlspecialchars("$key: $value") . '<br />'; 
5   } 

ch02-arrays/printNestedArray.php (23 lines)
2   function printNestedArray($a) { 
3     echo '<blockquote>'; 
4     foreach ($a as $key => $value) {
5       echo htmlspecialchars("$key: "); 
6       if (is_array($value)) { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
14 15 $arr = array( 16 'Roman' => 17 array('one' => 'I', 'two' => 'II', 'three' => 'III', 'four' => 'IV'), 18 'Arabic' => 19 array('one' => '1', 'two' => '2', 'three' => '3', 'four' => '4') 20 ); 21
Source code below from:
Pro PHP Security (Pro)
By Chris Snyder and Michael Southwell
Published 29 August, 2005
Average rating

      Powells     Alibris

CHAPTER03/resetPermissions.php (95 lines)
3  
4 // (sample) presets 
5 $presets = array( 'production-www'=>'root:www-0750',
6                   'shared-dev'=>':www-2770',
7                   'all-mine'=>'-0700'
8                   ); 
9  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
23 Ownership / group / permissions scheme, one of the following: 24 <?php 25 foreach( $presets AS $name=>$scheme ) { 26 print $name . '<br />'; 27 }

CHAPTER06/integrity.php (183 lines)
117  
118   // for each found... 
119   foreach( $found AS $fpath=>$file ) {
120  
121     // find matching record 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145 // content same so stats changed... which ones? 146 $changed = NULL; 147 foreach( $knownFile->stats AS $key=>$knownValue ) { 148 if ( $file->stats[ $key ] != $knownValue ) { 149 $changed .= "$key changed from $knownValue to " . $file->stats[ $key ] . ', ';
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
165 166 // now report on unlinked files 167 foreach( $known AS $kpath=>$file ) { 168 if ( empty( $found[ $kpath ] ) ) { 169 print "MISSING file at $kpath.\r\n";

CHAPTER06/openSSL.php (47 lines)
21  
22       // generate the pem-encoded private key 
23       $config = array( 'digest_alg'=>'sha1',
24                        'private_key_bits'=>1024,
25                        'encrypt_key'=>TRUE,
26                      ); 
27       $key = openssl_pkey_new( $config ); 

CHAPTER06/openSSLDemo.php (61 lines)
10   // a "Distinguished Name" is required for the public key 
11   $distinguishedName = array( 
12     "countryName" => "US",
13     "stateOrProvinceName" => "New York",
14     "localityName" => "New York City",
15     "organizationName" => "example.net",
16     "organizationalUnitName" => "Pro PHP Security",
17     "commonName" => "pps.example.net",
18     "emailAddress" => "csnyder@example.net"
19     ); 
20   $openSSL->makeKeys( $distinguishedName, $passphrase ); 

CHAPTER07/httpsDemo.php (31 lines)
6  
7   // create a context 
8   $options = array( 'http' => array( 'user_agent' => 'sslConnections.php' ),
9       'ssl' => array( 'allow_self_signed' => TRUE ) );
10   $context = stream_context_create( $options ); 
11  
Source code below from:
Spring Into PHP 5 (Spring Into)
By Steven Holzner
Published 12 April, 2005
Average rating

      Powells     Alibris

ch03/phpflip.php (29 lines)
11             </H1> 
12             <?php 
13                 $local_fruits = array("fruit1" => "apple", "fruit2" => "pomegranate", 
14                     "fruit3" => "orange");
15  
16                 foreach ($local_fruits as $key => $value) {
17                     echo "Key: $key; Value: $value<BR>"; 
18                 } 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22 $local_fruits = array_flip($local_fruits); 23 24 foreach ($local_fruits as $key => $value) { 25 echo "Key: $key; Value: $value<BR>"; 26 }

ch03/phpmultidimensional.php (24 lines)
15                 $test_scores["Mary"]["first"] = 87; 
16                 $test_scores["Mary"]["second"] = 93; 
17                 foreach ($test_scores as $outer_key => $single_array) {
18                     foreach ($single_array as $inner_key => $value) {
19                         echo "\$test_scores[$outer_key][$inner_key] = $value<BR>"; 
20                     } 

ch06/phpformdata.php (25 lines)
13                     if(is_array($value)){ 
14                         foreach($value as $item){ 
15                             echo $key, " => ", $item, "<BR>";
16                         } 
17                     } 
18                     else { 
19                         echo $key, " => ", $value, "<BR>";
20                     } 
21                 } 

ch09/phppolygon.php (35 lines)
2  
3 $points = array( 
4   0  => 120, 1  => 60,    
5  
6   2  => 130, 3  => 60,  
7  
8   4  => 160, 5  => 80,   
9  
10   6  => 180, 7  => 20,   
11  
12   8  => 150, 9  => 40,   
13  
14   10 => 110, 11 => 10,
15     
16   12 => 110, 13 => 80    
Source code below from:
Foundation PHP 5 for Flash (Foundation)
By David Powers
Published 01 March, 2005
Average rating

      Powells     Alibris

php files/Ch12/actions.php (115 lines)
41   $i=0; 
42   while ($row = $result->fetch_assoc()) { 
43     foreach ($row as $key => $value) {
44       // use the book_id to get a list of authors 
45       if ($key == 'book_id') { 

php files/Ch12/admin_funcs.php (56 lines)
1 <?php 
2 function insertMenu() { 
3   $pages = array('listbooks.php'    => 'List books',
4                  'listauthors.php'  => 'List authors',
5                  'listpub.php'      => 'List publishers',
6                  'new_book.php'     => 'New book',
7                  'new_auth_pub.php' => 'New author/publisher',
8                  'getprices.php'    => 'Get prices');
9   ?> 
10   <div id="menu"> 
11   <ul> 
12   <?php 
13   foreach ($pages as $file => $listing) {
14     echo '<li'; 
15     if (strpos($_SERVER['SCRIPT_FILENAME'],$file)) { 

php files/Ch12/admin_funcs01.php (28 lines)
1 <?php 
2 function insertMenu() { 
3   $pages = array('listbooks.php'    => 'List books',
4                  'listauthors.php'  => 'List authors',
5                  'listpub.php'      => 'List publishers',
6                  'new_book.php'     => 'New book',
7                  'new_auth_pub.php' => 'New author/publisher',
8                  'getprices.php'    => 'Get prices');
9   ?> 
10   <div id="menu"> 
11   <ul> 
12   <?php 
13   foreach ($pages as $file => $listing) {
14     echo '<li'; 
15     if (strpos($_SERVER['SCRIPT_FILENAME'],$file)) { 

php files/Ch12/admin_funcs02.php (34 lines)
1 <?php 
2 function insertMenu() { 
3   $pages = array('listbooks.php'    => 'List books',
4                  'listauthors.php'  => 'List authors',
5                  'listpub.php'      => 'List publishers',
6                  'new_book.php'     => 'New book',
7                  'new_auth_pub.php' => 'New author/publisher',
8                  'getprices.php'    => 'Get prices');
9   ?> 
10   <div id="menu"> 
11   <ul> 
12   <?php 
13   foreach ($pages as $file => $listing) {
14     echo '<li'; 
15     if (strpos($_SERVER['SCRIPT_FILENAME'],$file)) { 

php files/Ch12/admin_funcs03.php (56 lines)
1 <?php 
2 function insertMenu() { 
3   $pages = array('listbooks.php'    => 'List books',
4                  'listauthors.php'  => 'List authors',
5                  'listpub.php'      => 'List publishers',
6                  'new_book.php'     => 'New book',
7                  'new_auth_pub.php' => 'New author/publisher',
8                  'getprices.php'    => 'Get prices');
9   ?> 
10   <div id="menu"> 
11   <ul> 
12   <?php 
13   foreach ($pages as $file => $listing) {
14     echo '<li'; 
15     if (strpos($_SERVER['SCRIPT_FILENAME'],$file)) { 
Source code below from:
Beginning PHP5, Apache, and MySQL Web Development (Programmer to Programmer)
By Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, and Michael K. Glass
Published 04 February, 2005
Average rating

      Powells     Alibris

Appedix A Example Files/ch07ex01.php (86 lines)
20  
21   while (count($default_dir) > 0) { 
22     foreach ($default_dir as $dir_key => $startingdir) {
23      if ($dir = @opendir($startingdir)) { 
24        while (($file = readdir($dir)) !== false) { 

chapter 06/movie-rev01.php (107 lines)
71         <option value="" selected>Select an actor...</option> 
72 <?php 
73   foreach ($people as $people_id => $people_fullname) {
74 ?> 
75         <option value="<?php echo $people_id; ?>" ><?php  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87 <option value="" selected>Select a director...</option> 88 <?php 89 foreach ($people as $people_id => $people_fullname) { 90 ?> 91 <option value="<?php echo $people_id; ?>" ><?php

chapter 06/movie-rev02.php (154 lines)
107         <option value="" selected>Select an actor...</option> 
108 <?php 
109   foreach ($people as $people_id => $people_fullname) {
110     if ($people_id == $movie_leadactor) { 
111       $selected = " selected"; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
128 <option value="" selected>Select a director...</option> 129 <?php 130 foreach ($people as $people_id => $people_fullname) { 131 if ($people_id == $movie_director) { 132 $selected = " selected";

chapter 08/movie-rev01.php (165 lines)
116         <option value="" selected>Select an actor...</option> 
117 <?php 
118 foreach ($people as $people_id => $people_fullname) {
119   if ($people_id == $movie_leadactor) { 
120     $selected = " selected"; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
138 <option value="" selected>Select a director...</option> 139 <?php 140 foreach ($people as $people_id => $people_fullname) { 141 if ($people_id == $movie_director) { 142 $selected = " selected";

chapter 08/movie-rev02.php (186 lines)
119         <option value="" selected>Select an actor...</option> 
120 <?php 
121 foreach ($people as $people_id => $people_fullname) {
122   if ($people_id == $movie_leadactor) { 
123     $selected = " selected"; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
141 <option value="" selected>Select a director...</option> 142 <?php 143 foreach ($people as $people_id => $people_fullname) { 144 if ($people_id == $movie_director) { 145 $selected = " selected";
Source code below from:
PHP 5 Objects, Patterns, and Practice
By Matt Zandstra
Published 21 December, 2004
Average rating

      Powells     Alibris

final-code/04/personmake.php (64 lines)
23 die; 
24 $products = array(   
25                 array(  "id"=>1, 
26                         "type"=>"book", 
27                         "firstname"=>"willa",
28                         "mainname"=>"cather",
29                         "title"=>"My Antonia",
30                         "price"=>10.99,
31                         "numpages"=>300
32                 ), 
33                 array(  "id"=>2,
34                         "type"=>"cd", 
35                         "firstname"=>"The",
36                         "mainname"=>"Alabama 3",
37                         "title"=>"Exile on Coldharbour Lane", 
38                         "price"=>10.99, 

final-code/05/listing05.12.php (28 lines)
13 // Array 
14 // ( 
15 //     [0] => __construct
16 //     [1] => getPlayLength
17 //     [2] => getSummaryLine 
18 //     [3] => getProducerFirstName
19 //     [4] => getProducerMainName
20 //     [5] => setDiscount
21 //     [6] => getDiscount
22 //     [7] => getTitle
23 //     [8] => getPrice
24 //     [9] => getProducer
25 //     [10] => discountPrice
26 // ) 
27   

final-code/05/listing05.17.php (19 lines)
8 // Array 
9 // ( 
10 //     [cdproductplayLength] => 0
11 //     [coverUrl] =>
12 //     [shopproducttitle] =>
13 //     [shopproductproducerMainName] =>
14 //     [shopproductproducerFirstName] =>
15 //     [*price] =>
16 //     [shopproductdiscount] => 0
17 // ) 
18  

final-code/05/listing05.23.php (25 lines)
5  
6 // object(CdProduct)#1 (7) { 
7 //   ["playLength:private"]=>
8 //   float(60.33) 
9 //   ["coverUrl"]=>
10 //   string(0) "" 
11 //   ["title:private"]=>
12 //   string(25) "Exile on Coldharbour Lane" 
13 //   ["producerMainName:private"]=>
14 //   string(9) "Alabama 3" 
15 //   ["producerFirstName:private"]=>
16 //   string(3) "The" 
17 //   ["price:protected"]=>
18 //   float(10.99) 
19 //   ["discount:private"]=>
20 //   int(0) 
21 // } 

final-code/05/listing05.31.php (51 lines)
4     private $configData  
5             = array(  
6                     "PersonModule" => array( 'person'=>'bob' ),
7                     "FtpModule"    => array( 'host'  =>'example.com', 
8                                              'user'  =>'anon' ) 
9               ); 
10     private $modules = array();  
11  
12     function init() { 
13         $interface = new ReflectionClass('Module');  
14         foreach ( $this->configData as $modulename => $params ) {
15             $module_class = new ReflectionClass( $modulename ); 
16             if ( ! $module_class->isSubclassOf( $interface ) ) { 
Source code below from:
Professional PHP5 (Programmer to Programmer)
By Edward Lecky-Thompson, Heow Eide-Goodman, Steven D. Nowicki, and Alec Cove
Published 26 November, 2004
Average rating

      Powells     Alibris

ProPHP5CodeSeparations/ch08/DB_test.php (26 lines)
12 try { 
13   $table = "mytable"; 
14   $objDB->insert($table, array('myval' => 'foo') );
15   $objDB->insert($table, array('myval' => 'bar') );
16   $objDB->insert($table, array('myval' => 'blah') );
17   $objDB->insert($table, array('myval' => 'mu') );
18   $objDB->update($table, array('myval' => 'baz'), array('myval' => 'blah'));
19   $objDB->delete($table, array('myval' => 'mu'));
20   $data = $objDB->select("SELECT * FROM mytable"); 
21   var_dump($data); 

ProPHP5CodeSeparations/ch08/class.Database.php (150 lines)
47     // create a useful array for the SET clause 
48     $arUpdates = array(); 
49     foreach($arFieldValues as $field => $val) {
50       if(! is_numeric($val)) { 
51         //make sure the values are properly escaped 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58 // create a useful array for the WHERE clause 59 $arWhere = array(); 60 foreach($arConditions as $field => $val) { 61 if(! is_numeric($val)) { 62 //make sure the values are properly escaped
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
84 //create a useful array for generating the WHERE clause 85 $arWhere = array(); 86 foreach($arConditions as $field => $val) { 87 if(! is_numeric($val)) { 88 //make sure the values are properly escaped

ProPHP5CodeSeparations/ch08/new_class.Database.php (155 lines)
73      
74     $arSet = array(); 
75     foreach($arUpdates as $name => $value) {
76       $arSet[] = $name . ' = ' . $this->conn->quoteSmart($value); 
77     } 

ProPHP5CodeSeparations/ch11/class.Debugger.php (62 lines)
38  
39     if (is_array($var)) { 
40       foreach($var as $key => $value) {
41            
42           $string .= "<tr>\n" ; 

ProPHP5CodeSeparations/ch11/class.pgsqlLoggerBackend.php (134 lines)
61     //Take the query string in the form var=foo&bar=blah 
62     //and convert it to an array like 
63     // array('var' => 'foo', 'bar' => 'blah')
64     //Be sure to convert urlencoded values 
65     $queryData = $urlData['query']; 
Source code below from:
PHP 5 Power Programming (Bruce Perens Open Source)
By Andi Gutmans, Stig Bakken, and Derick Rethans
Published 27 October, 2004
Average rating

      Powells     Alibris

appendix_phpdoc/examples/sums/utility.php (33 lines)
22     $ret = $array1; 
23      
24     foreach ($array2 as $key => $element) {
25         if (isset ($ret[$key])) { 
26             $ret[$key] += $element; 

13/oo/sig1.php (24 lines)
18     $mag = new issues; 
19     $mag->title = "Time"; 
20     $mag->issues = array (1 => 'Jan 2003', 2 => 'Feb 2003');
21  
22     echo $mag->getTitle(2); 

07/examples/pear-error3.php (30 lines)
24  
25 function display_backtrace($bt) { 
26     foreach ($bt as $i => $f) {
27         printf("#%d %s:%d: %s%s%s()\n", $i, basename($f['file']), 
28                $f['line'], $f['class'], $f['type'], $f['function']); 

09/gd/bar.php (105 lines)
6  
7     $values = array( 
8         1993 => 3300, 1994 => 3450, 1995 => 4500, 1996 => 4400, 1997 => 4850, 1998 => 5100,
9         1999 => 5300, 2000 => 5700, 2001 => 6400, 2002 => 6700, 2003 => 6600, 2004 => 7100,
10     ); 
11     $max_value = 8000; 

09/streams/phpsuck.php (132 lines)
22 $term_sol = "\x1b[1G"; 
23 $severity_map = array ( 
24     0 => 'info   ',
25     1 => 'warning',
26     2 => 'error  '
27 ); 
28  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
107 /* Create context and set the notifier callback */ 108 $context = stream_context_create(); 109 stream_context_set_params($context, array ("notification" => "notifier")); 110 111 /* Open the target URL */
Source code below from:
Beginning PHP 5 and MySQL: From Novice to Professional
By W. J. Gilmore
Published 21 June, 2004
Average rating

      Powells     Alibris

chapter11/createdropdownfunction-v2.php (12 lines)
4       $dropdown = "<select name=\"$identifier\" multiple=\"$multiple\">"; 
5       $dropdown .= "<option name=\"\">$firstentry</option>"; 
6       foreach($pairs AS $value => $name)
7          $dropdown .= ($value==$selectedkey) ? "<option name=\"$value\" selected=\"selected\">$name</option>" : "<option name=\"$value\">$name</option>"; 
8       echo "</select>"; 

chapter11/createdropdownfunction.php (18 lines)
8  
9       // Create the dropdown elements 
10       foreach($pairs AS $value => $name)
11          $dropdown .= "<option name=\"$value\">$name</option>"; 
12  

chapter11/usingthecreatecrumbsfunction.php (31 lines)
22  
23    $crumb_site = "http://www.example.com/"; 
24    $crumb_labels = array("articles" => "Recent Articles",
25                                         "php" => "Advanced PHP",
26                                         "mysql" => "MySQL",
27                                         "pmnp" => "PHP 5 and MySQL Pro");
28  
29    echo create_crumbs($crumb_site, $crumb_labels); 

chapter14/streamcontextcreate.php (5 lines)
1 <?php 
2    $params = array("ftp" => array("overwrite" => "1"));
3    $context = stream_context_create($params); 
4    $fh = fopen("ftp://localhost/", "w", 0, $context); 

chapter15/ldapmodify.php (23 lines)
13  
14    /* Specify the attributes to be modified. */ 
15    $attrs = array("Company" => "Roman Empire", "Title" => "Pontifex Maximus");
16  
17    /* Modify the entry. */ 
Source code below from:
Web Database Applications with PHP & MySQL, 2nd Edition
By Hugh E. Williams and David Lane
Published 16 May, 2004
Average rating

      Powells     Alibris

wda/ch03/example.3-1.php (39 lines)
25   // More sophisticated multi-dimensional array 
26   $planets2 = array( 
27     "Mercury"=> array("dist"=>0.39, "dia"=>0.38),
28     "Venus"  => array("dist"=>0.72, "dia"=>0.95),
29     "Earth"  => array("dist"=>1.0,  "dia"=>1.0,
30                   "moons"=>array("Moon")),
31     "Mars"   => array("dist"=>0.39, "dia"=>0.53,
32                   "moons"=>array("Phobos", "Deimos")), 
33   ); 

wda/ch12/example.12-2.php (59 lines)
19    // Use the $context to get variable information for the function 
20    // with the error 
21    foreach($context as $name => $value)
22    { 
23      if (!empty($value)) 

wda/ch13/class.ezpdf.php (1555 lines)
19 //============================================================================== 
20  
21 var $ez=array('fontSize'=>10); // used for storing most of the page configuration parameters
22 var $y; // this is the current vertical positon on the page of the writing point, very important 
23 var $ezPages=array(); // keep an array of the ids of the pages, making it easy to go back and add page numbers etc. 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
148 return; 149 } 150 $def=array('gap'=>10,'num'=>2); 151 foreach($def as $k=>$v){ 152 if (!isset($options[$k])){ 153 $options[$k]=$v; 154 } 155 } 156 // setup the columns 157 $this->ez['columns']=array('on'=>1,'colNum'=>1); 158 159 // store the current margins
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192 if (isset($this->ezPages[$pageNum])){ 193 $this->ez['insertMode']=1; 194 $this->ez['insertOptions']=array('id'=>$this->ezPages[$pageNum],'pos'=>$pos); 195 } 196 break;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
291 } 292 $i = count($this->ez['pageNumbering']); 293 $this->ez['pageNumbering'][$i][$this->ezPageCount]=array('x'=>$x,'y'=>$y,'pos'=>$pos,'pattern'=>$pattern,'num'=>$num,'size'=>$size); 294 return $i; 295 }

wda/ch13/class.pdf.php (3075 lines)
71 * current colour for fill operations, defaults to inactive value, all three components should be between 0 and 1 inclusive when active 
72 */ 
73 var $currentColour=array('r'=>-1,'g'=>-1,'b'=>-1);
74 /** 
75 * current colour for stroke operations (lines etc.) 
76 */ 
77 var $currentStrokeColour=array('r'=>-1,'g'=>-1,'b'=>-1);
78 /** 
79 * current style that lines are drawn in 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
123 * it defaults to turning on the compression of the objects 124 */ 125 var $options=array('compression'=>1); 126 /** 127 * the objectId of the first page of the document
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
228 switch($action){ 229 case 'new': 230 $this->objects[$id]=array('t'=>'destination','info'=>array()); 231 $tmp = ''; 232 switch ($options['type']){
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
263 switch ($action){ 264 case 'new': 265 $this->objects[$id]=array('t'=>'viewerPreferences','info'=>array()); 266 break; 267 case 'add':

wda/ch13/example.13-2.php (49 lines)
11   // Output the book heading and author 
12   $doc->ezText("<u>Alice's Adventures in Wonderland</u>", 24, 
13                 array("justification"=>"center"));
14   $doc->ezText("by Lewis Carroll", 20, array("justification"=>"center"));
15  
16   // Create a little bit of space 
17   $doc->ezSetDy(-10); 
18  
19   // Output the chapter title 
20   $doc->ezText("Chapter 1: Down the Rabbit-Hole", 18, 
21                 array("justification"=>"center"));
22  
23   // Number the pages 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29 30 // Switch to two-column mode 31 $doc->ezColumnsStart(array("num"=>2, "gap"=>15)); 32 33 // Use the Times-Roman font for the text 34 $doc->selectFont("./fonts/Times-Roman.afm"); 35 36 // Include an image with a caption 37 $doc->ezImage("rabbit.jpg", "", "", "none"); 38 $doc->ezText("<b>White Rabbit checking watch</b>", 39 12,array("justification"=>"center")); 40 41 // Create a little bit of space
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43 44 // Add chapter text to the document 45 $doc->ezText($text,10,array("justification"=>"full")); 46 47 // Output the document
Source code below from:
Essential PHP Tools: Modules, Extensions, and Accelerators
By David Sklar
Published 15 March, 2004
Average rating

      Powells     Alibris

1590592808-1/Chapter01/ex15.php (6 lines)
1 $desserts = array('ice_cream' => 1, 'frozen_yogurt' => 1, 'sorbet' => 1);
2 if ($desserts[$_REQUEST['dessert']]) { 
3     $dbh->query('INSERT INTO ! (flavor) VALUES (?)', array($_REQUEST['dessert'], $_REQUEST['flavor'])); 

1590592808-1/Chapter01/ex34.php (6 lines)
1 $flavors= $dbh->getAssoc('SELECT id,flavor FROM ice_cream'); 
2 print '<select name="flavor">'; 
3 foreach ($flavors as $id => $flavor) {
4     print "<option value=\"$id\">$flavor</option>"; 
5 } 

1590592808-1/Chapter01/ex46.php (2 lines)
1 $dbh->autoExecute('ice_cream',array('flavor' => 'Blueberry', 'price' => 3.00), 
2 DB_AUTOQUERY_INSERT); 

1590592808-1/Chapter01/ex48.php (3 lines)
1 $dbh->autoExecute('ice_cream', 
2                   array('flavor' => 'Blueberry',  'price' => 3.00),
3                   DB_AUTOQUERY_UPDATE); 

1590592808-1/Chapter01/ex50.php (3 lines)
1 $dbh->autoExecute('ice_cream',array('flavor' => 'Blueberry', 'price' => 3.00),
2 DB_AUTOQUERY_UPDATE,'id = 23'); 
3  
Source code below from:
Advanced PHP Programming
By George Schlossnagle
Published 20 February, 2004
Average rating

      Powells     Alibris

ws/10-4.php (34 lines)
11   } 
12   function put($name, $tostore) { 
13     $storageobj = array('object' => $tostore, 'time' => time());
14     dba_replace($name, serialize($storageobj), $this->dbm); 
15   } 

ws/11-1.php (37 lines)
10  
11 class FibonacciTest extends PHPUnit_Framework_TestCase { 
12   private $known_values = array( 0 => 1,
13                              1 => 1,
14                              2 => 2,
15                              3 => 3,
16                              4 => 5,
17                              5 => 8,
18                              6 => 13,
19                              7 => 21,
20                              8 => 34,
21                              9 => 55);
22   public function testKnownValues() { 
23     foreach ($this->known_values as $n => $value) {
24       $this->assertEquals($value, Fib($n),  
25                           "Fib($n) == ".Fib($n)." != $value"); 

ws/12-1.php (94 lines)
30     $query = "SELECT * from users WHERE userid = :1"; 
31     $data = $dbh->prepare($query)->execute($userid)->fetch_assoc(); 
32     foreach( $data as $attr => $value ) {
33       $this->$attr = $value; 
34     } 

ws/16-amazon.php (46 lines)
33 $client->AuthorSearchRequest($authreq); 
34 $params = array( 
35 'author' => 'schlossnagle',
36 'page' => 1,
37 'mode' => 'books',
38 'tag' => 'webservices-20',
39 'type'        => 'lite',
40 'dev-tag'      => 'D3J98F4T2LIT7G',
41 ); 
42 // invoke the method  

ws/16-amazon2.php (22 lines)
7  
8 $params = array( 
9             'browse_node' => 18,
10             'page'        => 1,
11             'mode'        => 'books',
12             'tag'         => 'melonfire-20',
13             'type'        => 'lite',
14             'devtag'      => 'D3J98F4T2LIT7G'
15 ); 
16  
Source code below from:
Learning PHP 5
By David Sklar
Published July, 2004
Average rating

      Powells     Alibris

LearningPHP5Code/AppendixC/answer-10-1.php (42 lines)
24     die("Can't read article.html: $php_errormsg"); 
25 } 
26 $vars = array('{title}' => 'Man Bites Dog',
27               '{headline}' => 'Man and Dog Trapped in Biting Fiasco',
28               '{byline}' => 'Ireneo Funes',
29               '{article}' => "<p>While walking in the park today,
30 Bioy Casares took a big juicy bite out of his dog, Santa's Little 
31 Helper. When asked why he did it, he said, \"I was hungry.\"</p>", 
32               '{date}' => date('l, F j, Y'));
33  
34 foreach ($vars as $field => $new_value) {
35     $page = str_replace($field, $new_value, $page); 
36 } 

LearningPHP5Code/AppendixC/answer-10-2.php (69 lines)
57 arsort($addresses); 
58  
59 foreach ($addresses as $address => $count) {
60     // Don't forget the newline! 
61     if (fwrite($out_fh, "$count,$address\n") === false) { 

LearningPHP5Code/AppendixC/answer-4-1.php (20 lines)
1 $population = array('New York, NY' => 8008278,
2                     'Los Angeles, CA' => 3694820,
3                     'Chicago, IL' => 2896016,
4                     'Houston, TX' => 1953631,
5                     'Philadelphia, PA' => 1517550,
6                     'Phoenix, AZ' => 1321045,
7                     'San Diego, CA' => 1223400,
8                     'Dallas, TX' => 1188580,
9                     'San Antonio, TX' => 1144646,
10                     'Detroit, MI' => 951270);
11  
12 $total_population = 0; 
13 print "<table><tr><th>City</th><th>Population</th></tr>\n"; 
14 foreach ($population as $city => $people) {
15     $total_population += $people; 
16     print "<tr><td>$city</td><td>$people</td></tr>\n"; 

LearningPHP5Code/AppendixC/answer-4-2.php (46 lines)
1 Use asort() to sort by population. 
2 $population = array('New York, NY' => 8008278,
3                     'Los Angeles, CA' => 3694820,
4                     'Chicago, IL' => 2896016,
5                     'Houston, TX' => 1953631,
6                     'Philadelphia, PA' => 1517550,
7                     'Phoenix, AZ' => 1321045,
8                     'San Diego, CA' => 1223400,
9                     'Dallas, TX' => 1188580,
10                     'San Antonio, TX' => 1144646,
11                     'Detroit, MI' => 951270);
12  
13 $total_population = 0; 
14 asort($population); 
15 print "<table><tr><th>City</th><th>Population</th></tr>\n"; 
16 foreach ($population as $city => $people) {
17     $total_population += $people; 
18     print "<tr><td>$city</td><td>$people</td></tr>\n"; 

LearningPHP5Code/AppendixC/answer-4-3.php (34 lines)
1 // Separate the city and state name in the array so we can total by state 
2 $population = array('New York'     => array('state' => 'NY', 'pop' => 8008278),
3                     'Los Angeles'  => array('state' => 'CA', 'pop' => 3694820),
4                     'Chicago'      => array('state' => 'IL', 'pop' => 2896016),
5                     'Houston'      => array('state' => 'TX', 'pop' => 1953631),
6                     'Philadelphia' => array('state' => 'PA', 'pop' => 1517550), 
7                     'Phoenix'      => array('state' => 'AZ', 'pop' => 1321045), 
Source code below from:
Core PHP Programming, Third Edition
By Leon Atkinson and Zeev Suraski
Published 08 August, 2003
Average rating

      Powells     Alibris

corephp/10-11.php (92 lines)
9     //timeout after 5 seconds 
10     socket_set_option($socket, SOL_SOCKET, 
11         SO_RCVTIMEO, array('sec'=>5,'usec'=>0));
12  
13     //connect to the RtCW master server 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34 $port = (ord(substr($line, $i+5, 1)) * 256) + 35 ord(substr($line, $i+6, 1)); 36 $server[] = array('ip'=>$ip, 'port'=>$port); 37 } 38 }

corephp/10-2.php (10 lines)
4  
5     //display results 
6     foreach($mxrecord as $key=>$host)
7     { 
8         print("$host - $weight[$key]<br>\n"); 

corephp/11-19.php (8 lines)
2     //create an array 
3     $myArray = array( 
4         "Name"=>"Leon Atkinson",
5         "Profession"=>array("Programmer", "Author"), 
6         "Residence"=>"Martinez, California"
7     ); 
8 ?> 

corephp/11-20.php (13 lines)
1 <?php 
2     $location = array('Leon Atkinson'=>'home',
3         'john villarreal'=>'away',
4         'leon atkinson'=>'away', 
5         'Carl porter'=>'home',
6         'Jeff McKillop'=>'away',
7         'Rick Marazzani'=>'away',
8         'bob dibetta'=>'away',
9         'Joe Tully'=>'home'
10         ); 
11  

corephp/11-22.php (23 lines)
15  
16     //print out totals 
17     foreach($count as $number=>$count)
18     { 
19         print("$number: $count (" . 
Source code below from:
Usable Shopping Carts
By Jon Stephens, Jody Kerr, and Clifton Evans
Published 07 July, 2003
Average rating

      Powells     Alibris

tunein/html/checkout2.php (292 lines)
45     $req_length = count( $requirements ); 
46  
47     foreach($HTTP_POST_VARS as $field => $value)
48     { 
49       $field_name = explode("_", $field); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
201 </table> 202 <?php 203 foreach($HTTP_POST_VARS as $field => $value) 204 { 205 echo "<input type=\"hidden\" name=\"$field\" value=\"$value\" />\n";

tunein/html/testform.php (241 lines)
27     $req_length = count( $requirements ); 
28  
29     foreach($HTTP_POST_VARS as $field => $value)
30     { 
31       $field_name = explode("_", $field); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181 echo "<tr><th colspan=\"2\">Results:</th></tr><thead>\n"; 182 echo "<tbody><tr><th>Field:</th><th>Value:</th></tr>\n"; 183 foreach($HTTP_POST_VARS as $field => $value) 184 { 185 $field_name = explode( "_", $field);

tunein/includes/validate.inc (342 lines)
35     $req_length = count( $requirements ); 
36  
37     foreach($HTTP_POST_VARS as $field => $value)
38     { 
39       $field_name = explode("_", $field); 
Source code below from:
PHP MySQL Website Programming: Problem - Design - Solution
By Chris Lea, Mike Buzzard, Dilip Thomas, and Jessey-White Cinis
Published March, 2003
Average rating

      Powells     Alibris

DVD Life/_lib/_classes/class.newsletter.php (872 lines)
62         // and SMTP Port.  We use 'smtp' for our mail method so that we can use 
63         // an external SMTP server for relaying messages if nessisary.  
64         $this->_oMail = & Mail::factory("smtp", array("host" => SMTP_HOST, 
65                                                       "port" => SMTP_PORT));
66          
67         // Check and capture returned exceptions if present 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
207 // Build standard headers array 208 $aHead = array( 209 "From" => FROM_NAME."<".FROM_EMAIL.">", 210 "Subject" => $aNewsletter["Subject"] 211 ); 212
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
280 // Build static headers 281 $aHead = array( 282 "From" => FROM_NAME."<".FROM_EMAIL.">", 283 "Subject" => $aNewsletter["Subject"] 284 ); 285

DVD Life/_lib/_classes/class.orders.php (572 lines)
109             // This will define your transaction as well as your VeriSign user info 
110             $aTransArgs = array( 
111                 'USER' => 'mylogin',
112                 'PWD'  => 'mypassword',
113                 'PARTNER' => 'VeriSign',
114                 'TRXTYPE' => 'S',
115                 'TENDER'  => 'C',
116                 'AMT'     => $iAmount,
117                 'ACCT'    => $sCCNumber,
118                 'EXPDATE' => date("my",$iCCDate)
119             ); 
120          

DVD Life/_lib/_classes/class.rssfeed.php (294 lines)
256         // write out channel info 
257         $sRssFeed .= "  <channel rdf:about=\"" . $this->_aChannel["about"] . "\">\n"; 
258         foreach ( $this->_aChannel as $sKey => $sValue ) {
259             // "about" is an attribute, not an element 
260             if( 0 != strcmp($sKey , "about") ) { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
276 for( $i = 0 ; $i < count($this->_aItems) ; ++$i ) { 277 $sRssFeed .= " <item rdf:about=\"" . $this->_aItems[$i]["link"] . "\">\n"; 278 foreach( $this->_aItems[$i] as $sKey => $sValue ) { 279 $sRssFeed .= " <$sKey>$sValue</$sKey>\n"; 280 }

DVD Life/site/news/rss_tree.php (68 lines)
33  
34 // create base nodes for the channel 
35 $oChannel =& $oRoot->addChild("channel" , "" , array("rdf:about" => $sServer) );
36 $oChannel->addChild("title" , "DVD Life News"); 
37 $oChannel->addChild("link" , $sServer); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54 55 // ad the li resource for the items element 56 $oSeq->addChild("rdf:li" , "" , array("resource" => $sLink) ); 57 58 // add a new item element under the root node 59 $oItem =& $oRoot->addChild("item" , "" , array("rdf:about" => $sLink) ); 60 $oItem->addChild("title" , format($aNews[$i]["Title"])); 61 $oItem->addChild("link" , $sLink);
Source code below from:
PHP Graphics Handbook
By Jason E. Sweat, Allan Kent, and Mitja Slenc
Published 25 February, 2003
Average rating

      Powells     Alibris

ch-5,6,7/Ch05/3d/3dlib.php (448 lines)
42 { 
43     $result=array(); 
44     foreach($heights as $x => $row)
45         foreach($row as $y => $dist) {
46             $result[$x][$y]=( 
47                 $heights[$x+1][$y]+ 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
231 { 232 $count=0; 233 foreach($normals as $x=>$row) { 234 foreach($row as $y=>$normal) { 235 $ls=array(); 236
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
253 { 254 $result=array(); 255 foreach ($heights as $x=>$row) { 256 foreach($row as $y => $h) { 257 $d1=$h-$heights[$x][$y-1]; 258 $d2=$h-$heights[$x+1][$y];
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
283 { 284 $result=array(); 285 foreach($distances as $x=>$row) 286 foreach($row as $y=>$dist) { 287 $result[$x][$y]=$func($dist, $maxdist); 288 }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
422 } 423 424 foreach($result as $x => $col) 425 foreach($col as $y => $dist2) { 426 $result[$x][$y]=($tmp=sqrt($dist2)); 427 if ($tmp>$maxdist)

ch-5,6,7/Ch05/3d/chiseling.php (64 lines)
21 $mat->Add(new MaterialSpecular(255, 255, 255, 20)); 
22  
23 $mats=array("default" => $mat);
24 $lights=array(new DirectionalLight(-4, -6, 10)); 
25  

ch-5,6,7/Ch05/3d/graph.php (45 lines)
14 $mat->Add(new MaterialSpecular(255, 255, 255, 20)); 
15  
16 $mats=array("default" => &$mat);
17 $lights=array(new DirectionalLight(-6, -4, 8)); 
18  

ch-5,6,7/Ch05/3d/phongterms.php (86 lines)
43  
44 $mats=array( 
45     "ambient" => new MaterialAmbient(80, 80, 100),
46     "diffuse" => new MaterialDiffuse(255, 128, 50),
47     "specular" => new MaterialSpecular(255, 255, 255, 20),
48     "horizon" => $horizon,
49     "combined" => $mat
50 ); 
51  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 $lights[]=new DirectionalLight(-4, -6, 10); 60 61 foreach($mats as $name => $mat) { 62 if ($name=="combined") { 63 $imageout=imagecreatefrompng("sign_shadow.png"); 64 } else { 65 imagefilledrectangle($imageout, 0, 0, $sx, $sy, $white); 66 } 67 RenderNormals($imagein, $imageout, $heights, $normals, array("default" => $mat), $lights); 68 imagepng($imageout, "sign_".$name.".png"); 69 }

ch-5,6,7/Ch05/3d/smoothing.php (60 lines)
18 $mat->Add(new MaterialDiffuse(215, 215, 215)); 
19  
20 $mats=array("default" => $mat);
21 $lights=array(new DirectionalLight(-4, -6, 10)); 
22  
Source code below from:
Dreamweaver MX: Advanced PHP Web Development
By Glasshaus Author Team
Published January, 2003
Average rating

      Powells     Alibris

Documents and Settings/matthewma/My Documents/phpdwmx/error/errorhandler.php (51 lines)
9     $date = date("d/m/Y"); 
10     $time = date("H:i"); 
11 $errorType = array (1=>"Error", 2=>"Warning", 4=>"Parsing Error", 8=>"Notice", 16=>"Core Error", 32=>"Core Warning", 64=>"Compile Error",  128=>"Compile Warning", 256=>"User Error", 512 =>  "User Warning", 1024=>"User Notice");
12  
13 $outputHtml = " 

xsltClass.php (42 lines)
31         // Get XML Feed Data 
32         $xmlContent = $this->xml; 
33         $arguments = array('/_xml' => $xmlContent, '/_xsl' => $xslContent);
34         // Perform the XSL transformation 
35         $this->html = xslt_process($xparse, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); 

training/includes/jpgraph.php (6542 lines)
43 // Note 3: MUST be enabled to get background images working with GD2 
44 // Note 4: If enabled then truetype fonts will look very ugly 
45 // => You can't have both background images and truetype fonts in the same
46 // image until these bugs has been fixed in GD 2.01   
47 DEFINE('USE_TRUECOLOR',true); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1549 // Base file names for available fonts 1550 $this->font_fam=array( 1551 FF_COURIER => TTF_DIR."courier", 1552 FF_VERDANA => TTF_DIR."verdana", 1553 FF_TIMES => TTF_DIR."times", 1554 FF_HANDWRT => TTF_DIR."handwriting", 1555 FF_COMIC => TTF_DIR."comic", 1556 FF_ARIAL => TTF_DIR."arial", 1557 FF_BOOK => TTF_DIR."bookant"); 1558 } 1559
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3280 // Conversion array between color names and RGB 3281 $this->rgb_table = array( 3282 "aqua"=> array(0,255,255), 3283 "lime"=> array(0,255,0), 3284 "teal"=> array(0,128,128), 3285 "whitesmoke"=>array(245,245,245), 3286 "gainsboro"=>array(220,220,220),

training/includes/jpgraph_pie.php (715 lines)
36     var $legend_margin=6,$show_labels=true; 
37     var $themearr = array( 
38     "earth"     => array(136,34,40,45,46,62,63,134,74,10,120,136,141,168,180,77,209,218,346,395,89,430),
39     "pastel" => array(27,415,128,59,66,79,105,110,42,147,152,230,236,240,331,337,405,38),
40     "water"  => array(8,370,24,40,335,56,213,237,268,14,326,387,10,388),
41     "sand"   => array(27,168,34,170,19,50,65,72,131,209,46,393));
42     var $theme="earth"; 
43     var $setslicecolors=array(); 

training/mysql.php (369 lines)
242                 $xmlOutput .= "<ROW>"; 
243  
244                 foreach ($row as $key => $value) /* what is $key???? */
245                 { 
246                     $xmlOutput .= "<VALUE>"; 
Source code below from:
PHP Bible, 2nd Edition
By Tim Converse and Joyce Park
Published 11 September, 2002
Average rating

      Powells     Alibris

PHPBible_2ndEd/ch11/wc_handler_array.php (74 lines)
3 // This is the array where we keep our exercise names 
4 $name_array = array( 
5                     0 => 'Biking/cycling',
6                     1 => 'Running',
7                     2 => 'Soccer/football',
8                     3 => 'Stairclimber',
9                     4 => 'Weightlifting'
10                   ); 
11  
12 // This is the array where we keep our duration data 
13 $duration_array = array( 
14                     0 => '5 hours and 40 minutes',
15                     1 => '4 hours and 30 minutes',
16                     2 => '4 hours and 30 minutes',
17                     3 => '5 hours',
18                     4 => '7 hours and 30 minutes'
19                   ); 
20  
21 // Now step through the exercises and see which ones they chose 
22 if (is_array($_POST) && count($_POST) > 1) { 
23   $message = ''; 
24   foreach ($_POST['exercise'] as $key => $val) {
25     if ($val == 1) { 
26       $exercise_name = $name_array[$key]; 

PHPBible_2ndEd/ch11/wc_handler_ckbx.php (70 lines)
3 // This is the array where we keep our exercise names 
4 $name_array = array( 
5                     0 => 'Biking/cycling',
6                     1 => 'Running',
7                     2 => 'Soccer/football',
8                     3 => 'Stairclimber',
9                     4 => 'Weightlifting'
10                   ); 
11  
12 // This is the array where we keep our duration data 
13 $duration_array = array( 
14                     0 => '5 hours and 40 minutes',
15                     1 => '4 hours and 30 minutes',
16                     2 => '4 hours and 30 minutes',
17                     3 => '5 hours',
18                     4 => '7 hours and 30 minutes'
19                   ); 
20  

PHPBible_2ndEd/ch11/wc_handler_mult_arr.php (118 lines)
2  
3 // Exercise types 
4 $exercise_types = array(0 => 'Aerobic exercise',
5                         1 => 'Sports',
6                         2 => 'Strength training',
7                         3 => 'Stretching/flexibility'
8                        ); 
9  
10 // This is the multidimensional array where we keep our exercises 
11 $exercise_array =  
12   array(0 => array(0 => 'Biking/cycling',
13                    1 => 'Rowing',
14                    2 => 'Running',
15                    3 => 'Stairclimber',
16                    4 => 'Walking'
17                    ), 
18         1 => array(0 => 'Basketball',
19                    1 => 'Ice hockey', 
20                    2 => 'Soccer/football', 

PHPBible_2ndEd/ch12/exercise_include.php (118 lines)
2  
3 // Exercise types 
4 $exercise_types = array(0 => 'Aerobic exercise',
5                         1 => 'Sports',
6                         2 => 'Strength training',
7                         3 => 'Stretching/flexibility'
8                        ); 
9  
10 // This is the multidimensional array where we keep our exercises 
11 $exercise_array =  
12   array(0 => array(0 => 'Biking/cycling',
13                    1 => 'Rowing',
14                    2 => 'Running',
15                    3 => 'Stairclimber',
16                    4 => 'Walking'
17                    ), 
18         1 => array(0 => 'Basketball',
19                    1 => 'Ice hockey', 
20                    2 => 'Soccer/football', 

PHPBible_2ndEd/ch12/listing12_1.php (118 lines)
2  
3 // Exercise types 
4 $exercise_types = array(0 => 'Aerobic exercise',
5                         1 => 'Sports',
6                         2 => 'Strength training',
7                         3 => 'Stretching/flexibility'
8                        ); 
9  
10 // This is the multidimensional array where we keep our exercises 
11 $exercise_array =  
12   array(0 => array(0 => 'Biking/cycling',
13                    1 => 'Rowing',
14                    2 => 'Running',
15                    3 => 'Stairclimber',
16                    4 => 'Walking'
17                    ), 
18         1 => array(0 => 'Basketball',
19                    1 => 'Ice hockey', 
20                    2 => 'Soccer/football', 
Source code below from:
Web Database Applications with PHP & MySQL
By Hugh E. Williams and David Lane
Published March, 2002
Average rating

      Powells     Alibris

example.2-4.php (56 lines)
42   // More sophisticated multi-dimensional array 
43   $planets2 = array( 
44     "Mercury"=> array("dist"=>0.39, "dia"=>0.38),
45     "Venus"  => array("dist"=>0.39, "dia"=>0.95),
46     "Earth"  => array("dist"=>1.0,  "dia"=>1.0,
47                   "moons"=>array("Moon")),
48     "Mars"   => array("dist"=>0.39, "dia"=>0.53,
49                   "moons"=>array("Phobos", "Deimos")), 
50   ); 

example.6-6.php (119 lines)
24    
25   // Clean and trim the POSTed values   
26   foreach($HTTP_POST_VARS as $varname => $value)
27       $formVars[$varname] = trim(clean($value, 50)); 
28    

example.6-8.php (137 lines)
27    
28   // Clean and trim the POSTed values   
29   foreach($HTTP_POST_VARS as $varname => $value)
30       $formVars[$varname] = trim(clean($value, 50)); 
31    

example.8-4.php (138 lines)
36      session_register("formVars"); 
37    
38   foreach($HTTP_POST_VARS as $varname => $value)
39       $formVars[$varname] = trim(clean($value, 50)); 
40    

new/example.cart.5.php (130 lines)
29    // Clean up the data, and save the results in 
30    // an array 
31    foreach($HTTP_GET_VARS as $varname => $value)
32            $parameters[$varname] = clean($value, 10); 
33  
Source code below from:
Programming PHP
By Rasmus Lerdorf and Kevin Tatroe
Published March, 2002
Average rating

      Powells     Alibris

progphp-examples/ch05/5-1.php (18 lines)
1 $ages = array('Person'  => 'Age',
2               'Fred'    => 35,
3               'Barney'  => 30,
4           'Tigger'  => 8,
5           'Pooh'    => 40);
6  
7 //start table and print heading 

progphp-examples/ch05/5-3.php (45 lines)
11 } 
12  
13 $values = array('name'          => 'Buzz Lightyear',
14                 'email_address' => 'buzz@starcommand.gal',
15                 'age'           => 32,
16                 'smarts'        => 'some');
17  
18 if ($submitted) { 

progphp-examples/ch07/7-11.php (23 lines)
1 <?php 
2   // this is prefs.php 
3   $colors = array('black' => '#000000',
4                   'white' => '#ffffff',
5                   'red'   => '#ff0000',
6                   'blue'  => '#0000ff');
7   $bg_name = $_POST['background']; 
8   $fg_name = $_POST['foreground']; 

progphp-examples/ch07/7-13.php (16 lines)
1 <? 
2   $colors = array('black' => '#000000',
3                   'white' => '#ffffff',
4                   'red'   => '#ff0000',
5                   'blue'  => '#0000ff');
6   session_start(); 
7   session_register('bg'); 

progphp-examples/ch07/7-8.php (53 lines)
12 // $name = form field name ([] added by function) 
13 // $query = current query parameters 
14 // $options = array of value=>label for checkboxes
15 // any options present in $query are marked as checked 
16  
17 function make_checkboxes ($name, $query, $options) { 
18   foreach ($options as $value => $label) {
19     printf('%s <input type="checkbox" name="%s[]" value="%s" ', 
20             $label, $name, $value); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26 // the list of values and labels for the checkboxes 27 $personality_attributes = array( 28 'perky' => 'Perky', 29 'morose' => 'Morose', 30 'thinking' => 'Thinking', 31 'feeling' => 'Feeling', 32 'thrifty' => 'Spend-thrift', 33 'prodigal' => 'Shopper' 34 ); 35
Source code below from:
PHP Advanced for the World Wide Web Visual QuickPro Guide
By Larry Ullman
Published 15 December, 2001
Average rating

      Powells     Alibris

1/script_01_01.php (80 lines)
56 } 
57 } 
58 $r[$k] = array ('ws' => $ws, 'ls' => $ls); 
59 } 
60 ksort ($r);  

1/script_01_02.php (117 lines)
82     } 
83      
84     $results[$key] = array ('wins' => $wins, 'losses' => $losses); 
85 } 
86  

1/script_01_03.php (150 lines)
111     } 
112      
113     $results[$key] = array ('wins' => $wins, 'losses' => $losses); // Store each users performance in an array.
114 } 
115  

1/script_01_05.php (52 lines)
21         '; 
22          
23     foreach ($games as $key => $array) { // Use an array to print out each game.
24  
25         if ($key != 0) { // Don't print the Away Home line. 

1/script_01_08.php (48 lines)
17         '; 
18          
19     foreach ($games as $key => $array) { // Use an array to print out each game.
20  
21         if ($key != 0) { // Don't print the Away Home line. 
Source code below from:
Foundation PHP for Flash
By Steve Webster
Published September, 2001
Average rating

      Powells     Alibris

phpforflash/chapter10/fetchpoll.php (55 lines)
26  
27 // Remove any slashes from each element of $poll 
28 foreach($poll as $key => $value) {
29     $poll[$key] = stripslashes($value); 
30 } 

phpforflash/chapter10/listpolls.php (60 lines)
35 while($poll = mysql_fetch_array($result)) { 
36     // Remove any slashes from each element of $poll 
37     foreach($poll as $key => $value) {
38         $poll[$key] = stripslashes($value); 
39     } 

phpforflash/chapter2/multi_array.php (20 lines)
12  
13         // Loop to traverse each sub-array 
14         foreach($value as $key2 => $value2) {
15             echo "  $key2: $value2<br>\n"; 
16         } 

phpforflash/chapter2/sort_array.php (11 lines)
4 sort($reviewers); 
5  
6 foreach($reviewers as $id => $reviewer) {
7     echo "Reviewer $id: $reviewer<br>\n"; 
8 } 

phpforflash/chapter5/split.php (13 lines)
4 $sentences = split("[.!?]", $string); 
5  
6 foreach($sentences as $count => $sentence) {
7     print "$count: $sentence <br>\n"; 
8 } 

Not satisfied? Try this search biased towards software and programming:
Google