我要推数组key和value,但我不能array_push key =>值,该怎么办?
$con = mysqli_connect('localhost','root','','wp') or die (mysqli_error('Error:'));
$query = mysqli_query($con,'set names utf8')or die (mysql_error());
$qy = mysqli_query($con,"SELECT ID,post_title FROM wp_posts WHERE post_type='page' AND post_status='publish'")or die (mysql_error());
$arr = array();
while ($row = mysqli_fetch_array($qy)){
$id = "?page_id=".$row['ID'];
$title = $row['post_title'];
$arr[] = $id . "=>" . $title;
array_push($arr, "$id" => "$title");
}
plz帮助我..
感谢^ _^
[使用array_push()以'key => object']的形式向数组添加元素的可能的重复(http://stackoverflow.com/questions/4772314/using-array-push-to-add -elements-to-an-array-in-the-form-of-key-object) – 2011-01-23 04:50:18