如何在PHP中提取字符串的前100个字符 [英] How do you pull first 100 characters of a string in PHP

查看:627
本文介绍了如何在PHP中提取字符串的前100个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从字符串变量中提取前100个字符以放入另一个变量进行打印的方法.

I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.

是否有可以轻松实现此目的的功能?

Is there a function that can do this easily?

例如:

$string1 = "I am looking for a way to pull the first 100 characters from a string variable to put in another variable for printing.";
$string2 = 100charfunction($string1);
print $string2

获得:

I am looking for a way to pull the first 100 characters from a string vari

推荐答案

$small = substr($big, 0, 100);

对于字符串处理,这是一个具有很多功能的页面可能会对您的未来工作有所帮助.

For String Manipulation here is a page with a lot of function that might help you in your future work.

这篇关于如何在PHP中提取字符串的前100个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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