How would I remove the word 'ARRAY' from my search results. Here is the function that is performing the search. Also, I am pulling the data from a mysql db. Everything works great except the word 'ARRAY' printing on top of the results.
<?php
$sql_statement = "SELECT title, type, pubdate, isbn ";
$sql_statement .= "FROM booklib ";
if($keyword != 'ALL') {
$sql_statement .= "WHERE title LIKE '%$keyword%' ";
}
$sql_statement .= "ORDER BY title, type, pubdate, isbn ";
$result = mysql_query($sql_statement);
$outputDisplay = "";
$myrowcount = 0;
if(!$result) {
selectResults($statement, $db);
} else {
if($keyword == 'ALL') {
$outputDisplay = "<h1>Current Titles: </h1>";
} else {
$outputDisplay = "<h1>Current Titles that match: '$keyword'</h1>";
}
$outputDisplay .= list($title, $type, $pubdate, $isbn) = explode('*', $line);
$numresults = mysql_num_rows($result);
for($i = 0; $i < $numresults; $i++) {
$myrowcount++;
$row = mysql_fetch_array($result);
$title = $row['title'];
$category = $row['type'];
$pub_date = $row['pubdate'];
$isbn = $row['isbn'];
$outputDisplay .= "<br>$myrowcount.$title";
$outputDisplay .= "<br>Category: $category";
$outputDisplay .= "<br>Publication Date: $pub_date";
$outputDisplay .= "<br>ISBN: $isbn</br>";
}
print $outputDisplay;
getServer();
}
It is this line that does it:
$outputDisplay .= list($title, $type, $pubdate, $isbn) = explode('*', $line);
Assignment operations return the value that is being assigned. explode
returns an array that is assigned to the variables in list
. Basically, apart from the side effect of assigning variables in list
, it's as if your code was doing this:
$outputDisplay .= explode('*', $line);
If you try using an array as a string, PHP casts the array to a string that has the value "array"
. In addition, a notice is generated but it is probably not shown because your error_reporting
setting doesn't allow output of E_NOTICE
errors.