Jump to content
php.lv forumi

Par preg_replace funkciju


Recommended Posts

Tā nu saskāros ar problēmu, kad man izmeta šadu bridinajumu: Warning: preg_replace() [function.preg-replace]: Empty regular expression ............

koda gabaliņš kura dēļ šis bridinājums tika izmests ir zemāk:

 

$title = $_POST['title'];
$pattern = array('/ē/','/ū/','/ī/','/ā/','/š/','/ģ/','/ķ/','/ļ/','/ž/','/č/','/ņ/','/Ē/','/Ū/','/Ī/','/Ā/','/Š/','/Ģ/','/Ķ/','/Ļ/','/Ž/','/Č/','/Ņ/','/\//', '/\^/', '/\./', '/\$/', '/\|/','/\(/','/\)/','/\[/','/\]/','/\*/','/\+/','/\?/','/\{/','/\}/','/\,/','/!/','/@/','/#/','/%/','/&/','/=/',' ');
$replace = array('e','u','i','a','s','g','k','l','z','c','n','E','U','I','A','S','G','K','L','Z','C','N','','','','','','','','','','','','','','','','','','','','','','','','','','','_');
$titleUrl = preg_replace($pattern,$replace,$title);

 

$_POST['title'] ir vienkars raksta nosaukums.

Edited by Prayer !!
Link to post
Share on other sites

Tā nu saskāros ar problēmu, kad man izmeta šadu bridinajumu: Warning: preg_replace() [function.preg-replace]: Empty regular expression ............

koda gabaliņš kura dēļ šis bridinājums tika izmests ir zemāk:

 

$title = $_POST['title'];
$pattern = array('/ē/','/ū/','/ī/','/ā/','/š/','/ģ/','/ķ/','/ļ/','/ž/','/č/','/ņ/','/Ē/','/Ū/','/Ī/','/Ā/','/Š/','/Ģ/','/Ķ/','/Ļ/','/Ž/','/Č/','/Ņ/','/\//', '/\^/', '/\./', '/\$/', '/\|/','/\(/','/\)/','/\[/','/\]/','/\*/','/\+/','/\?/','/\{/','/\}/','/\,/','/!/','/@/','/#/','/%/','/&/','/=/',' ');
$replace = array('e','u','i','a','s','g','k','l','z','c','n','E','U','I','A','S','G','K','L','Z','C','N','','','','','','','','','','','','','','','','','','','','','','','','','','','_');
$titleUrl = preg_replace($pattern,$replace,$title);

 

$_POST['title'] ir vienkars raksta nosaukums.

 

Šādam repleisam iesaku uzmantot strtr();

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...