Reply to Re: Can't display column of multi-dimensional array

Your name:

Reply:


Posted by news on 09/18/05 03:37

Geoff Berrow wrote:
> Try setting up a simple multidimensional array and echoing it to screen.
> Then add your checking function when you understand what's going on.

Is this not a "simple multidimensional array"? (Wouldn't surprise me if
it's not.

OK, here's all of it, plus a bit of code to show what's in the array.
Using that' I've tried to manipulate it to match the a with the b, but
it's all coming out as individual items.
That made no sense.

$a = array();
$a[0][0] = "Name";
$a[0][1] = $name;
$a[1][0] = "Message";
$a[1][1] = $msg;
$a[2][0] = "Subject";
$a[2][2] = $subject;

function valid_field($field,$value)
{
// return FALSE if it contains characters which
// which AREN'T on the specified list
if(ereg("[^[:space:]a-zA-Z0-9_.-\!\\'\,]{1,}", $value))
{
$funcerror = $field." value of: <span
class='bolding'>\"".$value."\"</span> contains invalid characters.<br
/>";
return $funcerror;
}
else
{
return true;
}
}

while (list ($x, $tmp) = each ($a)) {
while (list ($y, $val) = each ($tmp)) {
echo "$x, $y, $val<br />";
}
}
foreach ($a as $v1) {
$fieldname = $v1;
foreach ($v1 as $v2) {
$returned = valid_field($fieldname,$v2);
if ($returned != "true") {
$error .= $returned;
$errflag = "1";
}
}
}


The while loop puts out the following:
0, 0, Name
0, 1, Liam
1, 0, Message
1, 1, Hello, this is a test msg.
2, 0, Subject
2, 2, It's a test subject.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация