0

I want to do treatments on two strings, and I must to know if there are spaces to stop my treatment and move on to the rest of characters I tested that but it doesn't rule the problem :

 for ($i = 0; $i < $lenght; $i++) {

                    if($text[$i] <> '' && $mask[$i] <> ''){

                        $nbrcrypted = $stringtonumber[$text[$i]] + $stringtonumber[$mask[$i]];
                        $resultat .= $numbertostring[$nbrcrypted];
                    }else{

                        $indice = false;
                    }                    
                }

how can I achieve that, thank you in advance

1
  • 1
    Define "whitespace." Do you mean spaces only? Horizontal tabs? Carriage returns? Line feeds? Commented Nov 17, 2012 at 17:28

2 Answers 2

2

if($text[$i] <> '' && $mask[$i] <> ''){ is useless, use if($text[$i] !== ' ' && $mask[$i] !== ' '){ for spaces

Sign up to request clarification or add additional context in comments.

Comments

1

I don't get what you're actually trying to do but if you want to test your string for whitespaces:

if ( strpos( $yourString, ' ' ) !== false )
    null; // string has whitespace(s)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.