note 73180 added to function.substr
| From: | neojoda at neojoda dot no-ip dot org | Date: | Mon, 12 Feb 2007 15:37:08 +0000 |
| Subject: | note 73180 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123280@lists.php.net to get a copy of this message | ||
Si tienes un string :
"a="Hola me llamo PEPE";
y quieres coge la palabra "lamo", haces:
piece ($a," ",3);
Funcion muy util bajo cache-mumps.
Saludos!
function piece ($entrada,$delim,$num){
$sortida="";
$cont = 1;
$find = 0;
$cadena = str_split($entrada);
foreach ($cadena as $key=>$value){
if ($value == $delim){
if ($cont==$num){
$find=1;
}else{
$cont++;
$sortida="";
}
}else{
if ($find!=1){
$sortida = $sortida.$value;
}
}
}
return $sortida;
}
----
Server IP: 130.206.1.5
Probable Submitter: 195.235.93.131 (proxied: 10.95.105.235)
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/73180
Del: integrated -- https://master.php.net/note/delete/73180/integrated
Del: useless -- https://master.php.net/note/delete/73180/useless
Del: bad code -- https://master.php.net/note/delete/73180/bad+code
Del: spam -- https://master.php.net/note/delete/73180/spam
Del: non-english -- https://master.php.net/note/delete/73180/non-english
Del: in docs -- https://master.php.net/note/delete/73180/in+docs
Del: other reasons-- https://master.php.net/note/delete/73180
Reject -- https://master.php.net/note/reject/73180
Search -- https://master.php.net/manage/user-notes.php