It's not working when I get the value from a url like selected.php?aa=2,3,
$mainclass = $_GET['aa'];
$classarray = explode(",", $mainclass);
$classarray = array_walk($classarray, 'intval');
$classa = implode(',', $classarray);
$makefeed = mysql_query("SELECT * FROM studentne开发者_开发百科w WHERE fieldname IN (".$classa.")"); while ($cc = mysql_fetch_array($makefeed)) { }
When using array_walk()
, the key/index is passed to the callback function (intval()
) as the second argument.
intval()
's second argument is the radix. You would not want the array index being passed in as the radix. This will return incorrect results (I assume you want them all as decimal).
Instead, use array_map()
.
Also, array_walk()
works by reference and returns a Boolean. So you are assigning this Boolean to the $classarray
variable.
change
$classarray = array_walk($classarray, 'intval');
to
array_walk($classarray, 'intval');
array_walk return boolean, not array. http://ru2.php.net/manual/en/function.array-walk.php
You need array_map.
Change
$classarray = array_walk($classarray, 'intval');
to
$classarray = array_map('intval' ,$classarray);
精彩评论