PHP/String/String Token
Содержание
String string token value
<?
$token = strtok("open-source HTML-embedded server-side Web scripting","-");
while($token){
print($token . "<BR>");
$token = strtok("-");
}
?>
String token for string split
<?
$token = strtok("open-source HTML-embedded server-side Web scripting"," -");
while($token){
print($token . "<BR>");
$token = strtok("-");
}
?>
String token: space
<?
$token = strtok("open-source HTML-embedded server-side Web scripting"," ");
while($token){
print($token . "<BR>");
$token = strtok(" ");
}
?>
Use more than one delimiter to split string
<?php
$info = "J. G:joe@wbex.ru|Vancouver, BC";
// delimiters include colon (:), vertical bar (|), and comma (,)
$tokens = ":|,";
$tokenized = strtok($info, $tokens);
// print out each element in the $tokenized array
while ($tokenized) {
echo "Element = $tokenized<br>";
// Don"t include the first argument in subsequent calls.
$tokenized = strtok($tokens);
}
?>