PHP/String/String Token — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:07, 26 мая 2010
Содержание
String string token value
<source lang="html4strict">
<? $token = strtok("open-source HTML-embedded server-side Web scripting","-"); while($token){
print($token . "
"); $token = strtok("-");
} ?>
</source>
String token for string split
<source lang="html4strict">
<? $token = strtok("open-source HTML-embedded server-side Web scripting"," -"); while($token){
print($token . "
"); $token = strtok("-");
} ?>
</source>
String token: space
<source lang="html4strict">
<? $token = strtok("open-source HTML-embedded server-side Web scripting"," "); while($token){
print($token . "
"); $token = strtok(" ");
} ?>
</source>
Use more than one delimiter to split string
<source lang="html4strict">
<?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
"; // Don"t include the first argument in subsequent calls. $tokenized = strtok($tokens); }
?>
</source>