note 96177 added to function.str-split
| From: | twicejr at gmail dot com | Date: | Fri, 12 Feb 2010 13:09:08 +0000 |
| Subject: | note 96177 added to function.str-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165908@lists.php.net to get a copy of this message | ||
I'd like to know if they'res a function that splits a string, but starts counting at the
right instead of the left...
Eg:
<?php
$str = '10007';
print_r(str_split_startAtRight($str));
//outputs:: Array( [0] => 10 [1] => 007)
?>
I solved it this way:
<?php
function str_split_startAtRight($str,$places)
{
$reversearr = array_reverse(str_split(strrev($str), $places));
foreach ($reversearr as $part) $str_split[] = strrev($part);
return $str_split;
}
?>
Anyone know a better way?
?>
----
Server IP: 69.147.83.197
Probable Submitter: 212.115.197.253
----
Manual Page -- http://www.php.net/manual/en/function.str-split.php
Edit -- https://master.php.net/note/edit/96177
Del: integrated -- https://master.php.net/note/delete/96177/integrated
Del: useless -- https://master.php.net/note/delete/96177/useless
Del: bad code -- https://master.php.net/note/delete/96177/bad+code
Del: spam -- https://master.php.net/note/delete/96177/spam
Del: non-english -- https://master.php.net/note/delete/96177/non-english
Del: in docs -- https://master.php.net/note/delete/96177/in+docs
Del: other reasons-- https://master.php.net/note/delete/96177
Reject -- https://master.php.net/note/reject/96177
Search -- https://master.php.net/manage/user-notes.php