note 116743 deleted from language.types.array by cmb
| From: | cmb@php.net | Date: | Fri, 15 May 2015 18:49:40 +0000 |
| Subject: | note 116743 deleted from language.types.array by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202535@lists.php.net to get a copy of this message | ||
Note Submitter: malay89space at gmail dot com
----
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... */
}
?>