str_shuffle
<<<
str_split str_word_count
>>>

7.101 Chaînes de caractères (Strings)
7 Index des fonctions
 Manuel PHP

. Introduction
. Pré-requis
. Installation
. Constantes prédefinies
. Voir aussi
. addcslashes
. addslashes
. bin2hex
. chop
. chr
. chunk_split
. convert_cyr_string
. count_chars
. crc32
. crypt
. echo
. explode
. fprintf
. get_html_translation_table
. hebrev
. hebrevc
. html_entity_decode
. htmlentities
. 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
. strpos
. strrchr
. strrev
. strripos
. strrpos
. strspn
. strstr
. strtok
. strtolower
. strtoupper
. strtr
. substr_count
. substr_replace
. substr
. trim
. ucfirst
. ucwords
. vprintf
. vsprintf
. wordwrap

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

[ Exemples avec str_split ]   PHP 5 CVS only

array  str_split ( string   string , int   split_length )

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

FALSE est retourné 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);

/* L'affichage donnera :

Array
(
    [0] => S
    [1] => a
    [2] => l
    [3] => u
    [4] => t
    [5] =>
    [6] => D
    [7] => a
    [8] => v
    [9] => e
)

Array
(
    [0] => Sal
    [1] => ut
    [2] => Dav
    [3] => e
)
*/
?>

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 preg_split , split , count_chars et str_word_count .

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