note 40512 added to function.str-split

From: Date: Fri, 05 Mar 2004 21:24:58 +0000
Subject: note 40512 added to function.str-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-66329@lists.php.net to get a copy of this message
<? // I wrote the following function as a solution to split a string into chunks. // The length of these chunks can be pre-defined. // I needed this as part of a program to replace each character of a nickname into pre-defined images. // Function function split_string($str,$chunklength) { $str = substr(chunk_split($str, $chunklength, ','), 0, -1); $arr = explode(',', $str); print_r($arr); } // Example 1 : $str = "Hakke"; $chunklength = 1; split_string($str, $chunklength); // Result : Array ( [0] => H [1] => a [2] => k [3] => k [4] => e ) // I hope this function can be useful for some people. ?> ---- Manual Page -- http://www.php.net/manual/en/function.str-split.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40512 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40512&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40512&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66329) next »