note 41083 added to control-structures.do.while

From: Date: Mon, 29 Mar 2004 20:36:51 +0000
Subject: note 41083 added to control-structures.do.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-67340@lists.php.net to get a copy of this message
function str_split($str,$num = '1') { if($num < 1) return FALSE; $arr = array(); for ($j = 0; $j < strlen($str); $j= $j+$num) { $h=0; if (substr($str,$h+$j+$num,1) != " ") { do{ $h+=1; if (($h+$j+$num) > strlen($str)) { break; } } while(substr($str,$h+$j+$num,1) != " "); } $arr[] = substr($str,$j,$num+$h); $j+=$h; } return implode("<BR>",$arr); } //// Example //// echo str_split ("Hello World!!! Good Morning.. This is Good",10); //// Results /// Hello World!!! Good Morning.. This is Good ---- Manual Page -- http://www.php.net/manual/en/control-structures.do.while.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41083 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41083&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41083&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67340) next »