Jump to content

[SOLVED] Check if a string contains something other than \n


papaface

Recommended Posts

if the string contains just \n, the STRLEN($string), of that string should be 2. if it's greater than two, it contains other character, or.

 

or you could find the last position of \n, get all the text before and after it, and make sure each one has a value besides ""

 

etc.

Oh sorry I thought it was for file parsing, so:

$s = "\n";
$n = strlen($s);
echo "len: ".$n."<br>";
$s = trim($s);
$n = strlen($s);
echo "len: ".$n."<br>";

e.g. trim get's rid of '\n', but that won't work in your case...

 

if(strstr($s, "\n") && (strlen($s) > 1))

Should work but not tried, other checks may be needed... i.e. if not contain!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.