PHP [RESOLVED] Split thank to Spark

Inscrit
26 Novembre 2012
Messages
18
Reactions
0
#1
Bonsoir,
La section "Questions/Réponses PHP" en php semble morte mais je tente quand même. J'ai besoin de votre aide pour utiliser "Split".
en VB.NET je fais comme ce-ci : Dim str As String = "1 - 2".Split(CChar("-"))(0) '1
Dim str As String = "1 - 2".Split(CChar("-"))(1) '2
Et apparemment en php c'est différend quelqu'un aurait une idée?

$str.split(pattern, string)

doc: http://php.net/manual/fr/function.split.php

Cordialement,
 

Sparkdaemon

Staff
Membre du personnel
Inscrit
7 Avril 2009
Messages
556
Reactions
3
#2
Re: Split

Code:
$Split = explode({Delimiter}, {String});

// Exemple

$String = 'W/A/W/D/S/A/S/Q/R';
$Delimiter = '/';
$SplittedString = explode($Delimiter, $String)
echo $SplittedString[0]; // Retournera W
echo $SplittedString[1]; // Retournera A
echo $SplittedString[2]; // Retournera W
( Voir: http://php.net/manual/fr/function.explode.php )
 
Haut Bas