jeudi 14 décembre 2017

what is the best way to check characters in string line

i have the code example:

  $str = '123456789101112131415';
  if(strlen($str) <10 )
  {
  echo "is not upto 10";
  }
  elseif(strlen($str) > 9) {
  echo 'the string is  10';
  }
  elseif(strlen($str) > 19) {
  echo 'the string is  20';
  }
  elseif(strlen($str) > 29) {
  echo 'the string is  30';
  }

my problem is how do sortout out my achievent when the string is hug and not specify on the (IF) list like above example:

   $str = '1234567891011121314151617181920 and more other';

what is the best way to get it without run a IF steatment 9 after the other.

Big thanks for your time and impact in my achievement

Aucun commentaire:

Enregistrer un commentaire