PHP中Strtok的疑惑 [英] Doubt regarding Strtok in PHP

查看:33
本文介绍了PHP中Strtok的疑惑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
    $string = "sandesh commented on institue international institute of technology";
    /* Use tab and newline as tokenizing characters as well  */
    $tok = strtok($string, " \n\t");
    echo $tok
    ?>

上面的代码给了我输出 sandesh.

The above code gives me output sandesh.

但是如果我想要输出commented onstitute International Institute of Technology",那么我应该如何修改上面的代码.

But if I want the output "commented on institute international institute of technology", then how should I modify the above code.

感谢和问候桑德斯

推荐答案

<?php
$string = "sandesh commented on institue international institute of technology";
echo substr($string,strpos($string," ")+1);

文档

编辑

我实际上需要第四个标记之后的字符串

i actually need the string after the fourth token

<?php
$string = "sandesh commented on institue international institute of technology";
$str_array = explode(" ",$string);
$str_array = slice($str_array,4);
echo implode(" ",$str_array);

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆