Re: Two dimensional arrays in PHP
| From: | Ignatius Teo | Date: | Thu, 22 Jun 2000 02:53:34 +0000 |
| Subject: | Re: Two dimensional arrays in PHP | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-574@lists.php.net to get a copy of this message | ||
You can use sizeof() to determine the number of elements in the array.
To view the elements, you can use:
<?php
$ary = array("help"=>"me","kiss"=>"the
girls","root"=>"admin");
echo sizeof($ary)."<br>\n";
while (list($index,$element)=each($ary)) {
echo "$index=$element<br>\n";
}
?>
Or, you can use: array_walk() - example is given in the manual.
The other thing you can do is:
<?php
define(RESOURCE, "http://www.php.net/manual/ref.array.php");
$know = false;
function rtfm($url="") {
// dummy user function - need to override
if (!$url) { return false; }
}
function try($something="") {
// dummy user function - need to override
if (!$something) { return false; }
}
function askfor($help) {
mail("php-windows@lists.php.net", "Help", $help);
}
while (!$know) {
$possible_solution = rtfm(RESOURCE);
if ($possible_solution) {
$know = try("first");
if ($know) {
break;
}
} else {
askfor("help");
exit;
}
}
// :-)
?>
Ignatius
----- Original Message -----
From: Nasir Ali <nal@mta.ca>
To: <php-windows@lists.php.net>
Sent: Thursday, June 22, 2000 11:48 AM
Subject: [PHP-WINDOWS] Two dimensional arrays in PHP
> Hi guys,
>
> I need help with PHP coding. Could someone tell me how to create,
> traverse, add values and insert values in a two dimensional array. Little
> code would be helpfull. I want to create this two dimensional array on
the
> fly so the both dimensions are unknown, means I'll have to use variable to
> define both dimensions unless there is some other way out.
>
> Please help...
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>