note 45910 added to function.strtr

From: Date: Thu, 23 Sep 2004 10:32:42 +0000
Subject: note 45910 added to function.strtr
Groups: php.notes 
Request: Send a blank email to php-notes+get-77234@lists.php.net to get a copy of this message
This function is usefull for accent insensitive regexp searches into greek (iso8859-7) text: (Select View -> Character Encoding -> Greek (iso8859-7) at your browser to see the correct greek characters) function gr_regexp($mystring){ $replacement=array( array("¶","Á","á","Ü"), array("¸","Å","å","Ý"), array("¹","Ç","ç","Þ"), array("º","É","é","ß","ú","À"), array("¼","Ï","ï","ü"), array("¾","Õ","õ","ý","û","à"), array("¿","Ù","ù","þ") ); foreach($replacement as $group){ foreach($group as $character){ $exp="["; foreach($group as $expcharacter){ $exp.=$expcharacter; } $exp.="]"; $trans[$character]=$exp; } } $temp=explode(" ", $mystring); for ($i=0;$i<sizeof($temp);$i++){ $temp[$i]=strtr($temp[$i],$trans); $temp[$i]=addslashes($temp[$i]); } return implode(".*",$temp); } $match=gr_regexp("Óêïõëéêïìõñìéãêüôñõðá êáé ÔæéæéñéÜ"); //The next query string can be sent to MySQL through mysql_query() $query= "Select column from table where column2 REGEXP '".$match."'"; ---- Manual Page -- http://www.php.net/manual/en/function.strtr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45910 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45910&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45910&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77234) next »