On Sunday 24 February 2002 04:03, jtjohnston wrote:
> I'm splitting mysql entries to build an array of author names called
> $authors.
>
> > As someone already suggested, you could use:
> > array_push($authors, explode(";", $mydata->AS));
>
> http://ccl.flsh.usherb.ca/db/authors_under_study.php
>
> It works, but still gets "First argument to array_push() needs to be an
> array" and fails before it gets to "print_r($authors)". Am I doing
> something wrong here:
[snip]
What array_push is doing is adding the *whole* array onto the existing array.
What you need is to add the *elements* of the array onto the existing array.
Try this:
$news = mysql_query("select id,AUS from $table");
$authors = array();
while ($mydata = mysql_fetch_object($news))
{
echo $mydata->id."|".$mydata->AUS."<hr>\n";
$tmp = explode(";", $mydata->AUS);
foreach($tmp as $val) {
array_push($authors, $val);
}
}
print_r($authors);
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Subtlety is the art of saying what you think and getting out of the way
before it is understood.
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php