str_shuffle
<<<
str_split str_word_count
>>>

6.36 Chaînes de caractères (Strings)
6 Référence des fonctions
 Manuel PHP

Introduction
Pré-requis
Installation
Constantes pré-définies
Voir aussi
addcslashes
addslashes
bin2hex
chop
chr
chunk_split
convert_cyr_string
convert_uudecode
convert_uuencode
count_chars
crc32
crypt
echo
explode
fprintf
get_html_translation_table
hebrev
hebrevc
html_entity_decode
htmlentities
htmlspecialchars_decode
htmlspecialchars
implode
join
levenshtein
localeconv
ltrim
md5_file
md5
metaphone
money_format
nl_langinfo
nl2br
number_format
ord
parse_str
print
printf
quoted_printable_decode
quotemeta
rtrim
setlocale
sha1_file
sha1
similar_text
soundex
sprintf
sscanf
str_ireplace
str_pad
str_repeat
str_replace
str_rot13
str_shuffle
->str_split
str_word_count
strcasecmp
strchr
strcmp
strcoll
strcspn
strip_tags
stripcslashes
stripos
stripslashes
stristr
strlen
strnatcasecmp
strnatcmp
strncasecmp
strncmp
strpbrk
strpos
strrchr
strrev
strripos
strrpos
strspn
strstr
strtok
strtolower
strtoupper
strtr
substr_compare
substr_count
substr_replace
substr
trim
ucfirst
ucwords
vfprintf
vprintf
vsprintf
wordwrap

6.36.60 str_split() Convertit une chaîne de caractères en tableau

[ Exemples avec str_split ]   PHP 5

array  str_split ( string   string , int   split_length )

Convertit une chaîne de caractères en tableau. Si le paramètre optionnel split_length est spécifié, le tableau retourné sera découpé en sous-parties, chacune de taille split_length , sinon, chaque sous-partie aura la taille d'un caractère.

Cette fonction retourne FALSE si split_length est inférieur à 1. Si la longueur de split_length est supérieure à celle de string , la chaîne entière est retournée dans le premier (et seul) élément du tableau.

Exemples d'utilisation de str_split

<?php

$str
= "Salut Dave";

$arr1 = str_split($str);
$arr2 = str_split($str, 3);

print_r($arr1);
print_r($arr2);

?>

Exemples liés à str_split

<?php

$str
= "Salut Dave";

print
$str{0};  // S
print $str{8};  // v

// Crée : array('S','a','l','u','t',' ','D','a','v','e')
$arr1 = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);

?>

Voir aussi chunk_split , preg_split , split , count_chars , str_word_count et for .

<< str_split >>
str_shuffle Chaînes de caractères (Strings) str_word_count