Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Aqui vai uma alternativa da função str_split() pra quem trabalha com versões anteriores ao PHP 5.
/**
* array str_split ( string String [, integer Length ] )
*
* Carlos Reche <carlosreche@yahoo.com>
*/
if (!function_exists("str_split")) {
function str_split($string, $length = 1) {
if ($length <= 0) {
trigger_error(__FUNCTION__."(): The the length of each segment must be greater then zero:", E_USER_WARNING);
return false;
}
$splitted = array();
$str_length = strlen($string);
$i = 0;
if ($length == 1) {
while ($str_length--) {
$splitted[$i] = $string[$i++];
}
} else {
$j = 0;
while ($str_length > 0) {
$splitted[$j++] = substr($string, $i, $length);
$str_length -= $length;
$i += $length;
}
}
return $splitted;
}
}Legal mesmo
da vontade de fazer as funções que só tem no php 5 para o pessoal que usa o php4
parabens
Boa vou ver se entro nessa de recriar funções do php 5 =)
Valeu, pessoal! :)
Também gostei da idéia de recriar mais funções do PHP 5 pra quem ainda tem que usar PHP 4.
Ótimo, Illidan.
Parabéns. http://forum.imasters.com.br/public/style_emoticons/default/clap.gif