note 47227 added to function.substr

From: Date: Sun, 07 Nov 2004 13:23:04 +0000
Subject: note 47227 added to function.substr
Groups: php.notes 
Request: Send a blank email to php-notes+get-80229@lists.php.net to get a copy of this message
Here is a function you may find handy. You input an string (for example 15986) and and a number (3) and it divides it from end by this number. Outputs (15 986) function Triplets($input, $by){ $output = substr($input, 0, strlen($input)%$by); for ($i = 0; $i < floor(strlen($input)/$by); $i++ ){ $output.= " ".substr($input, $i*$by+strlen($input)%$by,$by); } return $output; } ---- Manual Page -- http://www.php.net/manual/en/function.substr.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47227 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47227&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47227&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80229) next »