Notice: Undefined offset: 8192 in /www/k/a/u8542/public_html/classes/errors.php on line 121

Notice: Undefined offset: 8192 in /www/k/a/u8542/public_html/classes/errors.php on line 157

Notice: Undefined offset: 8192 in /www/k/a/u8542/public_html/classes/errors.php on line 121

Notice: Undefined offset: 8192 in /www/k/a/u8542/public_html/classes/errors.php on line 157
PHP - strtok

strtok

 

PHP -> Funkcie -> Funkcie pre prácu s reťazcami PHP -> strtok

Syntax


string strtok(string arg1, string arg2);

Popis


Príkaz jazyka PHP
strtok - tokenize string

strtok is used to tokenize a string. That is, if you have a string like "This is an example string" you could tokenize this string into its individual words by using the space character as the token.
Note that only the first call to strtok uses the string argument. Every subsequent call to strtok only needs the token to use, as it keeps track of where it is in the current string. To start over, or to tokenize a new string you simply call strtok with the string argument again to initialize it. Note that you may put multiple tokens in the token parameter. The string will be tokenized when any one of the characters in the argument are found.
Also be careful that your tokens may be equal to "0". This evaluates to false in conditional expressions.

Príklad


$string = "This is an example string";
$tok = strtok($string," ");
while($tok) {
echo "Word=$tok<br>";
$tok = strtok(" ");
}


Pozri aj


split, explode



vytlačiť článok  hľadať súvisiace články 



Chat ku článku

Vyhľadávanie na stránke
Reklama
Náhodný obrázok
náhodný obrázok
Kontakty

Martin Kasman, M Software
Smreková 3095/23
Email: martin@kasman.sk

Telefón: 0908 270 294