Jump to content

Deleting Chinese from database


Olavius

Recommended Posts

Hello,

 

For an assignment I have to insert tweets into a database specified by a number of search terms. For now it all seems to work, but there is one thing we can't filter. For some reason our English/Dutch searchterms sometimes insert Chinese tweets into our database. We need to delete those using triggers. Does anybody have any idea how to fix that?

Link to comment
https://forums.phpfreaks.com/topic/260185-deleting-chinese-from-database/
Share on other sites

Yes it is! But we've already got it working now;)

That's nice -- how?

 

We made a filter of acceptable characters, but we they dropped the assignment to use a trigger for it. The only little problem was that it sometimes filtered HTTP-links, but our teacher didn't mind that :D

 

This is the script:

 

<?php

function test_language($text){

$allowed = str_split("abcdefghijklmnopqrstuvwxyzàáäéèëÈÉÊËÌÍÎÏÁÙÚ^1234567890,./;’‘[]\-=~!@#$%^&*()_+{}|`:\"?><€ ");

$count = 0;

for($i=0;$i<=strlen($text);$i++){

for($j=0;$j<=count($allowed);$j++){

if(substr($text,$i,1)==$allowed[$j]){

$count++;

break;

}

}

}

if(strlen($text) == $count){

return true;

} else { return false; }

}

 

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.