Source for file string_functions.php
Documentation is available at string_functions.php
* An open source application development framework for PHP 4.3.2 or newer
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2006, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
// ------------------------------------------------------------------------
* CodeIgniter String Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/string_helper.html
// ------------------------------------------------------------------------
* Removes any leading/traling slashes from a string:
// ------------------------------------------------------------------------
* Removes slashes contained in a string or in an array
* @param mixed string or array
* @return mixed string or array
foreach ($str as $key =>
$val)
// ------------------------------------------------------------------------
* Prepara una/s cadena/s para ser enviada/s al HTML.
* @param mixed string or array $str
* @return mixed string or array
function escape($str, $charset=
'UTF-8')
foreach ($str as $key =>
$val)
$str[$key] =
escape($val, $charset);
$str[$key] =
htmlentities($str[$key], ENT_QUOTES, $charset);
// ------------------------------------------------------------------------
* Prepara una/s cadena/s para ser enviada/s a un input.
* @param mixed string or array $str
* @return mixed string or array
foreach ($str as $key =>
$val)
$str[$key] =
htmlentities($str[$key], ENT_QUOTES, $charset);
// ------------------------------------------------------------------------
* Prepara una/s cadena/s para ser enviada/s a una variable javascript.
* @param mixed string or array $str
* @return mixed string or array
foreach ($str as $key =>
$val)
// ------------------------------------------------------------------------
* Removes single and double quotes from a string
// ------------------------------------------------------------------------
* Converts single and double quotes to entities
return str_replace(array("\'","\"","'",'"'), array("'",""","'","""), $str);
// ------------------------------------------------------------------------
* Converts double slashes in a string to a single slash,
* except those found in http://
* http://www.some-site.com//index.php
* http://www.some-site.com/index.php
// ------------------------------------------------------------------------
* Reduces multiple instances of a particular character. Example:
* Fred, Bill,, Joe, Jimmy
* @param string the character you wish to reduce
* @param bool TRUE/FALSE - whether to trim the character from the beginning/end
$str =
trim($str, $character);
// ------------------------------------------------------------------------
* Useful for generating passwords or hashes.
* @param string type of random string. Options: alunum, numeric, nozero, unique
* @param integer number of characters
case 'alnum' :
$pool =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
case 'numeric' :
$pool =
'0123456789';
case 'nozero' :
$pool =
'123456789';
for ($i=
0; $i <
$len; $i++
)
// ------------------------------------------------------------------------
* Allows strings to be alternated. See docs...
* @param string (as many parameters as needed)
return $args[($i++ %
count($args))];
// ------------------------------------------------------------------------
* @param integer number of repeats
return (($num >
0) ?
str_repeat($data, $num) :
'');
* Quita los retornos de carro y saltos de linea de la cadena $str.
return str_replace(array("\r", "\n", "\r\n"), '', $str);
* Devuelve una cadena formateada para usar en PREG de modo que sea insensitiva
$return =
preg_replace('/a|à|á|â|ã|ä|å|ǻ|ā|ă|ą/iu', '[aàáâãäåǻāăą]', $return);
$return =
preg_replace('/e|è|é|ê|ë/iu', '[eèéêë]', $return);
$return =
preg_replace('/i|ì|í|î|ï/iu', '[iìíîï]', $return);
$return =
preg_replace('/o|ò|ó|ô|ö/iu', '[oòóôö]', $return);
$return =
preg_replace('/u|ù|ú|û|ü/iu', '[uùúûü]', $return);
* Convierte una cadena en IBM850 a ANSI
$aConv =
array(128=>
199,129=>
252,130=>
233,131=>
226,132=>
228,133=>
224,134=>
229,135=>
231,136=>
234,137=>
235,138=>
232,139=>
239,140=>
238,141=>
236,142=>
196,143=>
197,144=>
201,145=>
230,146=>
198,147=>
244,148=>
246,149=>
242,150=>
251,151=>
249,152=>
255,153=>
214,154=>
220,155=>
248,156=>
163,157=>
216,158=>
215,159=>
402,160=>
225,161=>
237,162=>
243,163=>
250,164=>
241,165=>
209,166=>
170,167=>
186,168=>
191,169=>
174,170=>
172,171=>
189,172=>
188,173=>
161,174=>
171,175=>
187,176=>
9617,177=>
9618,178=>
9619,179=>
9474,180=>
9508,181=>
193,182=>
194,183=>
192,184=>
169,185=>
9571,186=>
9553,187=>
9559,188=>
9565,189=>
162,190=>
165,191=>
9488,192=>
9492,193=>
9524,194=>
9516,195=>
9500,196=>
9472,197=>
9532,198=>
227,199=>
195,200=>
9562,201=>
9556,202=>
9577,203=>
9574,204=>
9568,205=>
9552,206=>
9580,207=>
164,208=>
240,209=>
208,210=>
202,211=>
203,212=>
200,213=>
305,214=>
205,215=>
206,216=>
207,217=>
9496,218=>
9484,219=>
9608,220=>
9604,221=>
166,222=>
204,223=>
9600,224=>
211,225=>
223,226=>
212,227=>
210,228=>
245,229=>
213,230=>
181,231=>
254,232=>
222,233=>
218,234=>
219,235=>
217,236=>
253,237=>
221,238=>
175,239=>
180,240=>
173,241=>
177,242=>
8215,243=>
190,244=>
182,245=>
167,246=>
247,247=>
184,248=>
176,249=>
168,250=>
183,251=>
185,252=>
179,253=>
178,254=>
9632,255=>
160);
for ($i=
0; $i<
$nCant; ++
$i) {
if (isset
($aConv[ord($cStr{$i})])) {
$cStr{$i} =
chr($aConv[ord($cStr{$i})]);
Documentation generated on Tue, 22 Nov 2011 13:29:00 -0200 by phpDocumentor 1.4.3