Re: Not Quite: how to build an array

From: Date: Sat, 23 Feb 2002 20:03:18 +0000
Subject: Re: Not Quite: how to build an array
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-85960@lists.php.net to get a copy of this message
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: $authors = array_push($authors, explode(";", $mydata->AUS)); ---------------snip-------------------------------- $news = mysql_query("select id,AUS from $table"); $authors = array(); while ($mydata = mysql_fetch_object($news)) { echo $mydata->id."|".$mydata->AUS."<hr>\n"; $authors = array_push($authors, explode(";", $mydata->AUS)); } print_r($authors); ---------------------snip--------------------- The data looks like: id->1 = "Zola, Émile"; id->2 = "Mendès, Catielle ??; Grutman; Bernabé, Jean; Andrade, Mario de; Sutherland, Ronald; Faulkner, William Harrison; Nabokov, Vladimir; Klein, Abraham Moses; Chassay, Jean-François; Glissant, Édouard; Martí, José; Jonassaint, Jean; Aguiar, Flavio"; id->3 = "Roberts, Charles George Douglas; Carman, Bliss; Scott, Francis Reginald; Gustafson, Ralph; Marriott, Anne; Kenneth, Leslie"; id->4 = "Roberts, Charles George Douglas; Carman, Bliss; Scott, Francis Reginald; Gustafson, Ralph; Marriott, Anne; Kenneth, Leslie"; id->5 = "Tremblay, Michel; Glassco, Bill; Freeman, David; Meunier, Claude; Gaboriau, Linda; Fennario, David;"; id->6 = "Tremblay, Michel; Laurendeau, André; Gélinas, Gratien; Glassco, Bill; Dassylva, Martial; Desbiens, Jean-Paul; Dubé, Marcel; Germain, Jean-Paul; Renaud, Jacques; Van Burik, John; Renaud Jacques;";

« previous php.general (#85960) next »