Предупреждение: preg_match_all () ожидает, что параметр 2 будет строкой, задан массив

class Forum_model extends CI_Model {

/**
* __construct function.
*
* @access public
* @return void
*/
public function __construct() {

parent::__construct();
$this->load->database();
$this->load->helper(array('url'));
}

function badfilter($text)
{
$filter_terms = array('\bass(es|holes?)?\b', '\bshit(e|ted|ting|ty|head)\b','\bf[ ]*u[ ]*c[ ]*k[]*\b','\bf+u+c+k+\b');
$filtered_text = $text;
foreach($filter_terms as $word)
{
$match_count = preg_match_all('/' . $word . '/i', $text, $matches);
for($i = 0; $i < $match_count; $i++)
{
$bwstr = trim($matches[0][$i]);
$filtered_text = preg_replace('/\b' . $bwstr . '\b/', str_repeat("*", strlen($bwstr)), $filtered_text);
}
}
return $filtered_text;
}

/**
* create_forum function.
*
* @access public
* @param string $title
* @param string $description
* @return bool
*/
public function create_forum($title, $description) {

$data = array(
'title'       => $title,
'slug'        => strtolower(url_title($title)),
'description' => $description,
'created_at'  => date('Y-m-j H:i:s'),
);

return $this->db->insert('forums', $data);

}

/**
* get_forum_id_from_forum_slug function.
*
* @access public
* @param string $slug
* @return int
*/
public function get_forum_id_from_forum_slug($slug) {

$this->db->select('id');
$this->db->from('forums');
$this->db->where('slug', $slug);
return $this->db->get()->row('id');

}

/**
* get_topic_id_from_topic_slug function.
*
* @access public
* @param string $topic_slug
* @return int
*/
public function get_topic_id_from_topic_slug($topic_slug) {

$this->db->select('id');
$this->db->from('topics');
$this->db->where('slug', $topic_slug);
return $this->db->get()->row('id');

}

/**
* get_forums function.
*
* @access public
* @return array of objects
*/
public function get_forums() {

$text=$this->db->get('forums')->result();
$this->badfilter($text);

}
}

приведенный выше код относится к контроллеру файла проекта, и он все еще после некоторой коррекции также показывает ошибку преобразования массива в строку.
пожалуйста, смотрите приведенный выше код

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector