Re: use of str_split

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Asim wrote:
Hi
when i try to use this function str_split() it shows me as invalid function

Are you using PHP 5? That function does not exist in PHP 4.

  what is solution
i want to split certain length of string into an array

// NB: UNTESTED

$string = 'This is a string';
$certainlength = 5;
$pos = 0;
$stringlen = strlen($string);
$array = array();
while ($pos < $stringlen)
{
	$array[] = substr($string, $pos, $certainlength);
	$pos += $certainlength;
}

// $array now contains an element for every $certainlength characters
// in $string

-Stut

--
http://stut.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux