[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Beginner PHP Tutorial – 45 – More on Expression Matching
by
Tags:
Comments
23 responses to “Beginner PHP Tutorial – 45 – More on Expression Matching”
-
echo preg_match('/ /', $str='abcd') ? 'withspaces' : 'without';
-
require 'tutorial44';
-
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.
-
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.
-
someone help me please!! what is the purpose of returning it? Explain please..
-
Good Job on making to the 45th Video guys !! Only 155 more to go !! Dont stop now 😉
-
am i the only one who watches these videos on x1.5 speed and rush clicks them as well ? 😛 they are very simple.
-
tutorial 44 is at index 30 in the playlist.
-
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.
-
you just made it complicated its simply pregmatch("/ "/ , bla bla)
-
O_o any one see tutorial no.44 ? 43 to 45 number 44 is unavailabel
-
$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.
-
<?php
$string = 'This is a string.';
if (preg_match('/ /', $string)) {
echo 'Match found.';
}
else {
echo 'No match found.';
}?>
-
WhAts the difference between JavaScript and php
-
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.
-
gottacommentfastnotimeforspace!
-
ghghghghghghg
-
or easier:
function has_space($string) {
return preg_match('/ /',$string);
}
no need for an if else statement.
-
Definitely a powerful function in PHP! 😉 Good job man!
-
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. -
This is hard to understand, but I can get through it.
-
155 videos more to go.
-
155 videos more to go.
Leave a Reply