Search the Community
Showing results for tags 'strpos'.
-
Hey guys I'm trying to use strpos to stop a form when someone use a word not allowed in the text area and get different message depending of the word. For example Badword1 return Message 1, Badword2 return Message 2..... but..... Instead of that I get all the message one after all... if (strpos(cP("description"), 'Badword1' , 'Badword2') !== false) { $error = true; $error_text .= "<div class=\"error-msg2\"><p>Message 1</p></div>"; } if (strpos(cP("description"), 'Badword3' , 'Badword4') !== false) { $error = true; $error_text .= "<div class=\"error-msg2\"><p>Message 2</p></div>"; } if (strpos(cP("description"), 'Badword5' , 'Badword6') !== false) { $error = true; $error_text .= "<div class=\"error-msg2\"><p>Message 3</p></div>"; } Can you please help me, and maybe find what wrong here
-
Hey everyone! Any ideas why $idPos below is returning zero/false? I've tried '//v//', '\/v\/' (backslash, forward slash, v, backslash, forward slash) I can't seem to get it to work. $url = 'https://www.youtube.com/v/9hYj_PFZGug'; $idPos = stripos($url, '/v/'); Thanks, Jeff
-
Say you have a string that you know has two, and exactly two, periods in it, like this... $string = "3.12.8" How can you grab the three different values that are separated by periods (in this case, 3, 12 and ? I was thinking use strpos to find the position of the first period, then could use that info to grab everything up to that position. But then I couldn't figure out how you would find the position of the SECOND period. And even if I could get the exact positions of the two periods, it seems like there should be an easier way to simply retrieve values separated by specific characters. Is there a specific function for this type of thing, or was my initial though correct with having to do it in two parts essentially (find positions of periods, then use that knowledge to get the values)? Thanks!
-
I'm trying to filter out the rows of a uploaded csv that have the word "lokaal" (classroom) in the 3th colom, but this doesn't work. What does work: When I search for just one letter (for example the o) $findneedle is true, so it works Putting $haystack="lokaal 5"; in the coding also works (but that is just usable for testpurposes) echo $haystack does result in a correct value, so the csv is read correctly <? $handle = fopen($_FILES['file']['tmp_name'], "r"); $data = fgetcsv($handle, 1000, ";"); //Remove if CSV file does not have column headings while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $haystack=$data[2]; $needle='lokaal'; $findneedle=strpos($needle, $haystack); if($findneedle !== false) { //rest of the coding } ?> The CSV looks like this 2013;Class 1;Zelfstudie;31-12-2013 0:00:00;1-1-1900 9:00:00;1-1-1900 12:00:00; 2013;Class 2;lokaal 5;27-12-2013 0:00:00;1-1-1900 15:00:00;1-1-1900 17:00:00; Am I overlooking something? I hope someone can help me.
-
I want to look for the word "pant" within this string: "Pants: I'm going to be late!" How would I do this? I'd prefer it if I wasn't case sensitive search! This is how I'm trying to do it at the moment but it's not working! $status = "Pants: I'm going to be late!"; $changeValue = strtok($status, " "); $changeValue = strtolower($changeValue); $imageValue = "images/"; if($changeValue == "pant:"){ // if I change this value to "pants:" with the colon it works however I only want to search for the word "pant" without the "s" or the ":" $imageValue .= "pant.PNG"; }