what i try to do ?
i try to make code to found if there duplicate data into database or not ,that data it text Content written by users .
so i make sql query to get result of row pagetext
from database and clean it from any Signs And coordinate (font color, font size, and font type) and image links or any links , and same i do it for Variable $post['message']
that get Content of text area ..
than i check if Content of $post['message']
is same Content of pagetext
or not !
Full code :
// FUNCTION TO CLEAN TEXT
function stripBBCode($text_to_search)
{
$pattern = '|[[\/\!]*?[^\[\]]*?]|si';
$replace = '';
return preg_replace($pattern, $replace, $text_to_search);
}
// MYSQL QUERY
$ckeck = $db->query_read(" SELECT pagetext FROM " . TABLE_PREFIX . " post ");
$ckeck_num = mysql_num_rows($ckeck);
while ($ckeckpagetext = $db->fetch_array($ckeck))
{
// RESULT FROM QUERY - here i try to make ARRAY BY [square brackets]
$pagetext[] = stripBBCode($ckeckpagetext['pagetext']);
$pagetext[] = preg_replace('/[\s]+/mu','', $pagetext);
$pagetext[] = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $pagetext);
// Variable
$message = stripBBCode($post['message']);
$message = preg_replace('/[\s]+/mu','',$message );
$message = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $message);
// LOOP
for($x=0; $x<$ckeck_num; $x++)
{
// CHECK IF THERE duplicate TEXT OR NOT
if ($message == $pagetext[$x])
{
$ckeck_duplicate = 1;
}else{
$ckeck_duplicate = 2;
}
}
}
My problem ? my code Almost correct , but my problem in those lines [square brackets] . when i try great array for my result
// RESULT FROM QUERY
$pagetext[] = stripBBCode($ckeckpagetext['pagetext']);
$pagetext[] = preg_replace('/[\s]+/mu','', $pagetext);
$pagetext[] = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $pagetext);
if i used only first line without used preg_replace
the code works good .
when i use [square brackets] for a
$pagetext[] = stripBBCode($ckeckpagetext['pagetext']);