note 116743 added to language.types.array

From: Date: Sat, 21 Feb 2015 15:50:02 +0000
Subject: note 116743 added to language.types.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-201778@lists.php.net to get a copy of this message
In response to ianodebe at yahoo dot com... <?php $q = array("How many states are there in Nigeria:", "What is the capital city of Anambra state:", "What year was Nigeria amalgamated:" ); $a = array( array(20, 39, 36, 40), array( "Awka", "Aniocha", "Ogidi", "Owerri"), array( "1940", "1914", "1960", "1941") ); $cq = count($q); // No. of elements in question array... $ca = count($a); // No. of elements in answer array... $j = 0; // denotes the key of nested array elements of ans array... for( $i=0; $i<$cq; $i++) //traversing thro elements of que array... { echo ($i+1).". ".$q[$i]."?...<br>"; foreach($a[$j] as $value ) // traversing thro nested array elements of ans array... { echo "\t".$value."<br>"; } $j++; /* incermenting the key of subsequent nested arrays of ans arrays outside foreach so that in increments with each que array element... */ } ?> ---- Server IP: 103.21.58.218 Probable Submitter: 106.208.35.82 ---- Manual Page -- http://php.net/manual/en/language.types.array.php Edit -- https://master.php.net/note/edit/116743 Del: integrated -- https://master.php.net/note/delete/116743/integrated Del: useless -- https://master.php.net/note/delete/116743/useless Del: bad code -- https://master.php.net/note/delete/116743/bad+code Del: spam -- https://master.php.net/note/delete/116743/spam Del: non-english -- https://master.php.net/note/delete/116743/non-english Del: in docs -- https://master.php.net/note/delete/116743/in+docs Del: other reasons-- https://master.php.net/note/delete/116743 Reject -- https://master.php.net/note/reject/116743 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201778) next »