Beginner PHP Tutorial – 45 – More on Expression Matching

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

23 responses to “Beginner PHP Tutorial – 45 – More on Expression Matching”

  1. Kevin Wang Avatar

    echo preg_match('/ /', $str='abcd') ? 'withspaces' : 'without';

  2. Sonic260 Avatar

    preg_match already returns "true" or "false" after checking the string, so has_space can be rewritten as:

    function has_space($string){
    return preg_match('/ /', $string);
    }

    and the return statement will return "true" or "false" without making another if statement in the function.

    It saves a couple of lines of code.

  3. RR Dev Avatar

    From a purely educational perspective, it would have been easier to explain if you hadn't used the placeholder variable in the function definition when you called the function later in the script. It creates an association between the two, when really one is just a placeholder and the other is a variable.

  4. Aww Waa Avatar

    someone help me please!! what is the purpose of returning it? Explain please..

  5. Rider 007 Avatar

    Good Job on making to the 45th Video guys !! Only 155 more to go !! Dont stop now 😉

  6. Platwn Ace Avatar

    am i the only one who watches these videos on x1.5 speed and rush clicks them as well ? 😛 they are very simple.

  7. Vaibhav Kharche Avatar

    tutorial 44 is at index 30 in the playlist.

  8. guscles25 Avatar

    is php tutorial 44 missing? seems to skip straight to 45. ah it's just not added to the playlist but it is in your video archive's.

  9. Gēoffrey Eng Ātkinson Avatar

    you just made it complicated its simply pregmatch("/ "/ , bla bla)

  10. Majestic Barrack Avatar

    O_o any one see tutorial no.44 ? 43 to 45 number 44 is unavailabel

  11. Amit Singh Avatar

    $a= 'are';
    $text= 'hello how are you?';

    if(preg_match($a, $text)) {

    echo 'match found!'.'<br>';
    }

    else{
    echo 'no match found'.'<br>';
    }

    this is not working if I use a variable instead of a word.

  12. V. Peters Avatar

    <?php

    $string = 'This is a string.';

    if (preg_match('/ /', $string)) {
        echo 'Match found.';
        }
        else {
            echo 'No match found.';
        }

    ?>

  13. Saad Haider Avatar

    WhAts the difference between JavaScript and php

  14. Janis L. Avatar

    this method to test is useless I know much better,but this is very good method to test function is true or false,so I clicked the like buuton.Thanks you dude.

  15. Gabriel Badiola Avatar

    gottacommentfastnotimeforspace!

  16. Jack Stean Avatar

    or easier:

    function has_space($string) {

    return preg_match('/ /',$string);

    }

    no need for an if else statement.

  17. Pogi Ako Avatar

    Definitely a powerful function in PHP! 😉 Good job man!

  18. Jason Armani Avatar

    Everyone take note : If you're only looking for a string inside another string then use strpos() or strstr() instead as they will be faster. 🙂
    Source : The manual page on preg_match() from PHP's site.

  19. Cj Vaans Avatar

    This is hard to understand, but I can get through it.

  20. Alex Smith Avatar

    155 videos more to go.

Leave a Reply

Your email address will not be published. Required fields are marked *