您的位置:首页 > 编程语言 > PHP开发

php substr()根据起点和终点访问字符串

2015-02-17 16:50 239 查看
php substr()

<?php

        $a="zhaogz@job@163.com";

        $email_array = explode('@',$a);

        echo $email_array[0];

        echo "<br>";

        echo $email_array[1];

        echo "<br>";

        echo $email_array[2];

        echo "<br>";

        $new_email = join ('@',$email_array);

        echo $new_email."<br />";

        $b = substr($new_email,0,6);  // 起点是0,终点是6(终点可不填,意思为到字符串终点为止),读取字符串b为zhaogz

        echo $b."<br />";

        $c = substr($new_email,-7);  //负数为从右向左数,读取的字符串c为163.com

        echo $c;

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 工作