[英]Enter next line by verifying if string length has reached the specified number
I want to create a condition in PHP to check whether the length of the string has reached the specified value and if the condition is true then show rest of the characters on the next line. 我想在PHP中创建一个条件来检查字符串的长度是否已达到指定值,如果条件为true,则在下一行显示其余字符。 The string is passed from a form using POST method. 使用POST方法从表单传递字符串。
你在寻找wordwrap()函数吗?
considering the specific length is 10 考虑到具体长度是10
if(strlen($_POST['str']) > 10)
echo "\n". substr($_POST['str'],10);
$max_length = 100;
$string = 'mystring'; // or whatever
if(strlen($string) > $max_length){
$sub_str = substr($string, $max_length);
}
echo $sub_str
on a new line if $sub_str
is set. 如果设置了$sub_str
则在新行上回显$sub_str
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.