note 48202 deleted from function.substr by philip

From: Date: Wed, 26 Feb 2014 00:09:20 +0000
Subject: note 48202 deleted from function.substr by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198717@lists.php.net to get a copy of this message
Note Submitter: vitalic#pisem.net ---- Split $string after each $pos, by $space Example: <?php spaceStr('1836254','-',3); ?> Would return '183-625-4'; <?php function spaceStr($string,$space,$pos) { $cpos=$pos; while ($cpos<strlen($string)) { $string=substr($string,0,$cpos).$space.substr($string,$cpos); $cpos+=strlen($space)+$pos; }; return $string; } ?>

« previous php.notes (#198717) next »