note 93794 added to function.preg-replace

From: Date: Tue, 29 Sep 2009 22:19:20 +0000
Subject: note 93794 added to function.preg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-161154@lists.php.net to get a copy of this message
please NEVER use a function like the one in the note below (CapsLock()). Reasons why not to use it: - There is already a strtoupper() function that converts characters to upper case. -There is no reason to declare 27 different variables inside a function when you need to replace a string. You can use the same original variable: $string = preg_replace('a','A',$string); $string = preg_replace('b','B',$string); -There is no need to use preg_replace for simple string replacements. use str_replace('a','A',$string) - it is much much much faster. -This function won´t work for latin characters like á,ã,é,í,ó,ú... -tired of writing more reasons..... ---- Server IP: 187.16.23.134 Probable Submitter: 200.162.9.50 ---- Manual Page -- http://www.php.net/manual/en/function.preg-replace.php Edit -- https://master.php.net/note/edit/93794 Del: integrated -- https://master.php.net/note/delete/93794/integrated Del: useless -- https://master.php.net/note/delete/93794/useless Del: bad code -- https://master.php.net/note/delete/93794/bad+code Del: spam -- https://master.php.net/note/delete/93794/spam Del: non-english -- https://master.php.net/note/delete/93794/non-english Del: in docs -- https://master.php.net/note/delete/93794/in+docs Del: other reasons-- https://master.php.net/note/delete/93794 Reject -- https://master.php.net/note/reject/93794 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161154) next »