note 96177 rejected from function.str-split by thiago

From: Date: Fri, 12 Feb 2010 13:47:18 +0000
Subject: note 96177 rejected from function.str-split by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-165909@lists.php.net to get a copy of this message
Note Submitter: twicejr at gmail dot com ---- 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? ?>

« previous php.notes (#165909) next »