Reputation:
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. The string is passed from a form using POST method.
Upvotes: 1
Views: 141
Reputation: 5239
considering the specific length is 10
if(strlen($_POST['str']) > 10)
echo "\n". substr($_POST['str'],10);
Upvotes: 1
Reputation: 5399
$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.
Upvotes: 1