Search code examples
phpsolrmodxmodx-revolution

Strip_tags() expects parameter 1 to be string, array given


hopefully this is a quick and easy fix. I'm using Solr to search on my MODX site and am having some troubles with the PHP... I'm quite a noob when it comes to this stuff. Anyways, the error I'm getting is:

PHP warning: strip_tags() expects parameter 1 to be string, array given

Here's the function:

public function sanitize($text) {
    $text = strip_tags($text);
    $text = preg_replace('/(\[\[\+.*?\]\])/i', '', $text);
    return $this->modx->stripTags($text);
}

I don't think I can change the spot that's generating $text, so I have to change the function somehow to accept an array (of strings, I would assume). Can anyone help me rewrite this?

Thanks in advance!!!


Solution

  • Well this means that the $text passed to your function is an array and not a string. However you can try using implode function() to convert an array to a string. Hope this helps.