Title: PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) &#8230;
Last modified: January 5, 2025

---

# PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) …

 *  Resolved [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/)
 * PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be 
   of type ?array, string given in …/public_html/wp-content/plugins/bbp-style-pack/
   includes/functions_bugs.php:675
 * On line 675 of bbp-style-pack/includes/funcions_bugs.php it has the following
   line:
 *     ```wp-block-code
       <li><?php echo implode( "</li>\n<li>", esc_html($errors) ); ?></li>
       ```
   
 * The variable $errors is an array and esc_html expects a string. I think this 
   should be changed to to this:
 *     ```wp-block-code
       <li><?php echo esc_html( implode( "</li>\n<li>", $errors ) ); ?></li>
       ```
   

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18226620)
 * thanks, yes that looks better, I’ll test and release a new version soon
 *  Thread Starter [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18228365)
 * I think it would be better to call esc_html when putting the error strings into
   the $errors array rather than calling it on the implode function otherwise I 
   think that esc_html may incorrectly escape the <li> tags.
    -  This reply was modified 1 year, 5 months ago by [joneiseman](https://wordpress.org/support/users/joneiseman/).
 *  Plugin Author [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18228401)
 * I’ve been working on this
 * The li tags seem to be ok, but yes I agree it would be better, except that the
   errors are generated in bbpress not my plugin, and I am not a bbpress developer,
   and unlikely that they will change it.
 * So your code is the best for the moment !!
 * I’ll release a new version soon !
 * Thanks again for your really useful input
 *  Plugin Author [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18230128)
 * should be fixed in 6.2.1 just released, please confirm
 *  Thread Starter [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18230591)
 * Well it no longer crashes but it doesn’t display the list correctly. I tested
   it out with this shortcode:
 *     ```wp-block-code
       add_shortcode("myshortcode", 'myshortcodefunc');function myshortcodefunc(){    $arr = [ "str1", "str2", "str3" ];    return '<li>' . esc_html(implode("</li>\n<li>", $arr)) . '</li>';}
       ```
   
 * This displayed as a list if I removed the esc_html. However, if I leave in the
   esc_html in there then it looks like this:
    - str1</li> <li>str2</li> <li>str3
 * Changing the function to this works correctly:
 *     ```wp-block-code
       function myshortcodefunc(){    $arr = [ "str1", "str2", "str3" ];    $ret = "";    foreach ($arr as $str) {        $ret .= '<li>' . esc_html($str) . '</li>';    }    return $ret;}
       ```
   
 *  Thread Starter [joneiseman](https://wordpress.org/support/users/joneiseman/)
 * (@joneiseman)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18230647)
 * Using wp_kses_post instead of esc_html also works:
 *     ```wp-block-code
       function myshortcodefunc(){    $arr = [ "str1", "str2", "str3" ];    return '<li>' . wp_kses_post(implode("</li>\n<li>", $arr)) . '</li>';}
       ```
   
 *  Plugin Author [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [1 year, 5 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18231594)
 * Thanks, we were both getting to the same conclusion (kses_post), and thanks for
   your continued input
 * I am now planning on
 *     ```wp-block-code
       <li><?php echo wp_kses_post(implode( "</li>\n<li>", $errors )); ?></li>
       ```
   
 * I’ll release this tomorrow
 *  Plugin Author [Robin W](https://wordpress.org/support/users/robin-w/)
 * (@robin-w)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18239537)
 * fixed in 6.2.3 just released

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘PHP Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) …’
is closed to new replies.

 * ![](https://ps.w.org/bbp-style-pack/assets/icon-256x256.jpg?rev=2706563)
 * [bbp style pack](https://wordpress.org/plugins/bbp-style-pack/)
 * [Support Threads](https://wordpress.org/support/plugin/bbp-style-pack/)
 * [Active Topics](https://wordpress.org/support/plugin/bbp-style-pack/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/bbp-style-pack/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/bbp-style-pack/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Robin W](https://wordpress.org/support/users/robin-w/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/php-fatal-error-uncaught-typeerror-implode-argument-2-array/#post-18239537)
 * Status: resolved