note 40512 deleted from function.str-split by aidan

From: Date: Tue, 01 Jun 2004 06:18:04 +0000
Subject: note 40512 deleted from function.str-split by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70385@lists.php.net to get a copy of this message
Note Submitter: info@hakke.be ---- <? // 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. ?>

« previous php.notes (#70385) next »