You didn't supply any information about you foreach() loop, but it works
like

foreach ($array as $string)
        print "$element<br>\n";

And explode() returns an array, so I think you need to do it like this:

$array = explode(";", $string);
array_push($authors, $array); // You could use foreach() here as well


Niklas


-----Original Message-----
From: jtjohnston [mailto:[EMAIL PROTECTED]] 
Sent: 22. helmikuuta 2002 8:48
To: [EMAIL PROTECTED]
Subject: [PHP] foreach not in reach


Question 1:
How can I append strings to my authors array?
Me thinks this doesn't work :§) ?
$authors .= explode(";", $mydata->KW);
I'm getting "Invalid argument supplied for foreach()"

Question 2:
Once I get this working, I want to (a) alphabetise the contents of the
array, (b) count repititions, (c) elimintate copies, and create an array
I can print with tow things "$author[i]\t$counter[i]", so I end up with
something like:

Adam    2
Louis    5
John    3
Mary    8

------------------------------------------------------------------------

$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$news = mysql_query("select KW from $table");

while ($mydata = mysql_fetch_object($news))
{
$authors .= explode(";", $mydata->KW);
}

foreach ($authors as $author)
{
echo "$author<br>\n";
}
------------------------------------------------------------------------

I'm learning, slowly but surely Martin :)
J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to