Chinaunix首页 | 论坛 | 博客
  • 博客访问: 34924
  • 博文数量: 4
  • 博客积分: 185
  • 博客等级: 民兵
  • 技术积分: 45
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-19 10:25
文章分类

全部博文(4)

文章存档

2012年(4)

最近访客

分类: Python/Ruby

2012-04-01 15:47:19


substr()用法如下

  1. $value = substr($string, $offset, $count);
  2. $value = substr($string, $offset);
  3. substr($string, $offset, $count) = $newstring;
  4. substr($string, $offset, $count, $newstring); # same as previous
  5. substr($string, $offset) = $newtail;


$value = substr($string, $offset, $count);

  1. $string = "good good start, day day up!";
  2. substr($string, 0, 4) = "bad";
  3. print $string;
    result
  1. bad good start, day day up!


$value = substr($string, $offset, $count,$newstring);
  1. $string = "good good start, day day up!";
  2. substr($string, 5, 4, "bad");
  3. print $string;

result

  1. good bad start, day day up!

 
 

$value = substr($string, $offset);
  1. $string = "good good start, day day up!";
  2. substr($string, 0) = "bad";
  3. print $string;

result

  1. bad

阅读(3227) | 评论(0) | 转发(0) |
0

上一篇:Showing Usage

下一篇:unpack()访问子串

给主人留下些什么吧!~~