我有一个语句 $latest_pollid
并且想把它放在一个看起来像这样的数组中:
array(
'comment_status' => 'open',
'ping_status' => 'closed',
'post_author' => $author_id,
'post_name' => $slug,
'post_title' => $pollq_question,
'post_status' => 'publish',
'post_type' => 'post',
'post_content' =>
)
对于 post_content
项,我想将其设置如下:
[投票 ID=$latest_pollid]
但我知道我不能按原样将这两者混为一谈。有什么方法可以将 $latest_pollid
中的值放在这个语句中吗? 'post_content' => '[poll id=xxxxxx]'
使用 sprint 类型的字符串可以做到这一点吗?
非常感谢任何帮助。
谢谢
最佳答案
尝试
'post_content' => '[poll id=' . $latest_pollid . ']'
或
array(
'comment_status' => 'open',
'ping_status' => 'closed',
'post_author' => $author_id,
'post_name' => $slug,
'post_title' => $pollq_question,
'post_status' => 'publish',
'post_type' => 'post',
'post_content' => '[poll id=' . $latest_pollid . ']'
)
关于PHP - 在数组中显示 $ 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34432571/