有没有办法将超过1个变量绑定到php中的单个变量?

时间:2019-05-03 05:24:23

标签: php mysql mysqli

我正在使用准备语句

<?php
if ($no_of_result > 0) { // have record that matches with query
    mysqli_stmt_bind_result($stmt, $post_category, 
                                   $post_title, 
                                   $post_author, 
                                   $post_date, 
                                   $post_image, 
                                   $post_content, 
                                   $post_tags, 
                                   $post_comment_counts, 
                                   $post_status, 
                                   $post_views_counts, 
                                   $post_likes);
    while ($row = mysqli_fetch_array($result)) { // have posts
         get_body($row);
     }
} else { // no posts and last page
     echo "<h3 class='title is-3 has-text-centered'> No Result Found <h3/>" ;
}
mysqli_free_result($result);
?>

我要转换所有这些变量

$post_category,
$post_title, 
$post_author, 
$post_date, 
$post_image, 
$post_content, 
$post_tags, 
$post_comment_counts, 
$post_status, 
$post_views_counts, 
$post_likes

以用作$row的方式。函数get_body()仅需要一个参数,所以也许我可以做类似$row['post_category']$row[1]的事情,并且只需将一个参数传递给函数get_body()即可访问所有变量? / p>

php的新手,所以我什至不知道它是否可行

0 个答案:

没有答案