英文:
PHP8: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given
问题
我正在使用以下代码,此前一直有效,但在升级到PHP8后,出现以下错误:
Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given
$content = apply_filters('the_content', get_the_content());
$content_table = explode('</p>', $content);
$content_table[3] .= $spot1;
$content_table[6] .= $spot2;
$content_table[9] .= $spot3;
$content_table[12] .= $spot4;
$content_table[15] .= $spot5;
$content2 = implode('</p>', $content_table);
echo $content2;
如何修复这个问题?
英文:
I am using the following code, which has been working previously, but after upgrading to PHP8 I get the error of:
Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given
$content = apply_filters( 'the_content', get_the_content() );
$content_table = explode("</p>", $content);
$content_table[3] .= $spot1;
$content_table[6] .= $spot2;
$content_table[9] .= $spot3;
$content_table[12] .= $spot4;
$content_table[15] .= $spot5;
$content2 = implode($content_table, "</p>");
echo $content2;
How can I fix this?
答案1
得分: 1
Sure, here's the translated content:
最后很简单,只需反转implode语句:
$content2 = implode("</p>", $content_table);
英文:
Simple enough in the end, just had to reverse the implode statement:
$content2 = implode("</p>", $content_table);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论