note 97145 added to function.array-slice
| From: | yuwas at ht dot cx | Date: | Sun, 04 Apr 2010 13:54:47 +0000 |
| Subject: | note 97145 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167685@lists.php.net to get a copy of this message | ||
By combining this with str_split() and implode(),slices can also be excerpted from strings with the
following simple function:
<?php
function str_slice($string,$offset,$length=999,$preserve_keys=False){
if( $length == 999 ){ $length = strlen($string)-$offset };
$slice_arr = array_slice(str_split($string),$offset,$length,$preserve_keys);
return implode($slice_arr);
};
?>
Perhaps there's a better way to preset $length.
----
Server IP: 85.214.154.209
Probable Submitter: 87.153.103.115
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/97145
Del: integrated -- https://master.php.net/note/delete/97145/integrated
Del: useless -- https://master.php.net/note/delete/97145/useless
Del: bad code -- https://master.php.net/note/delete/97145/bad+code
Del: spam -- https://master.php.net/note/delete/97145/spam
Del: non-english -- https://master.php.net/note/delete/97145/non-english
Del: in docs -- https://master.php.net/note/delete/97145/in+docs
Del: other reasons-- https://master.php.net/note/delete/97145
Reject -- https://master.php.net/note/reject/97145
Search -- https://master.php.net/manage/user-notes.php