我们仅在第一次调用 strtok() 函数时使用了 string 参数。在首次调用后,该函数仅需要 split 参数,这是因为它清楚自己在当前字符串中所在的位置。

如需分割一个新的字符串,请再次调用带 string 参数的 strtok()

<!DOCTYPE html>
<html>
<body>

<?php
$string = "Hello world. Beautiful day today.";
$token = strtok($string, " ");

while ($token !== false)
{
echo "$token<br>";
$token = strtok(" ");
}
?>
  
</body>
</html>

 

 

参考:

https://www.w3school.com.cn/php/func_string_strtok.asp

 

 

相关文章:

  • 2022-12-23
  • 2022-02-24
  • 2022-02-13
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
猜你喜欢
  • 2021-12-25
  • 2021-07-01
  • 2021-06-27
  • 2021-08-19
  • 2021-08-28
  • 2022-12-23
相关资源
相似解决方案