note 97145 deleted from function.array-slice by cmb

From: Date: Sun, 29 Dec 2019 12:29:09 +0000
Subject: note 97145 deleted from function.array-slice by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213702@lists.php.net to get a copy of this message
Note Submitter: yuwas at ht dot cx ---- 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.

« previous php.notes (#213702) next »