Questions tagged [stripos]

stripos is the case-insensitive counterpart of strpos, returning the position of a given string within another string.

67 questions
1
vote
1 answer

preg match and stripos

I have an csv import function. There is in the csv a column like this ''1. Informatik, Bachelor, 2015, 1. Fachsemester'' or this '' 1. Mathematik, LA Bachelor Gymnasien, 2015,'' If in the line exists 'LA' , so $fachrichtung='Lehramt',…
egokyniker
  • 31
  • 9
1
vote
7 answers

String search function to return boolean if needle is found in haystack

I'm writing a simple function which will convert string containing url into a clickable link. Convertion itself is simple but part of basic validation if a string contains one of protocol prefixes seems to be surprisingly difficult. Currently my…
spectatorx
  • 373
  • 2
  • 7
  • 22
1
vote
2 answers

Cleaning up a very long if statement

I have a very long list of strings called $stringfilter1 $stringfilter2 etc all the way up to $stringfilter50 I have another string $reporteremail and I want to make a conditional statement whereby if any of the $stringfilter strings is present in…
whatscool
  • 317
  • 2
  • 18
1
vote
1 answer

Display first if a string contains 2 elements of my array - PHP,

I have a array containing a word list : myArray = array(first, time, sorry, table,...); and a JSON : { "products": { "0": { "title": "myTitle", "url": "xxxxxx", "id": "329102" }, "1":…
dibs
  • 174
  • 1
  • 12
1
vote
3 answers

How to validate Vine URL and allow HTTP or HTTPS using PHP

How can this be changed to allow either HTTP or HTTPS for a Vine URL? $vineURL = 'https://vine.co/v/'; $pos = stripos($url_input_value, $vineURL); if ($pos === 0) { echo "The url '$url' is a vine URL"; } else { echo "The url '$url' is not a…
Cofey
  • 11,144
  • 16
  • 52
  • 74
1
vote
4 answers

mb_stripos() in PHP won't work correctly

This code: setlocale(LC_ALL, 'pl_PL', 'pl', 'Polish_Poland.28592'); $result = mb_stripos("ĘÓĄŚŁŻŹĆŃ",'ęóąśłżźćń'); returns false; How to fix that? P.S. This stripos returns false when special characters is used is not correct answer. UPDATE: I…
user3383675
  • 1,041
  • 5
  • 12
  • 31
1
vote
2 answers

Extending stripos($_SERVER['REQUEST_URI'] to check for more URLs

I am using stripos to modify an active navigation class, It works like a charm. However I need to add another REQUEST_URI to check in the string and…
1
vote
2 answers

Understanding stripos offset?

Let's say I've a small array () : $array = array( 'Pantin', 'Paris', 'Paris', 'Puhahaa', 'Ptdr', 'Roumanie', 'Rlolo' ); What I want to do? Simply get all words that start with the 'r'…
Ydhem
  • 928
  • 2
  • 14
  • 36
1
vote
2 answers

Search for string and output array

My Code: $css=" .class1{ padding:10px 15px 0 auto; padding:10px 150px 0 20px; padding:13px 30px 10px 50px; padding:24px 1px 0 -20px; } "; Function below extracts content between [padding:] and [;] …
Montaser El-sawy
  • 800
  • 1
  • 8
  • 14
0
votes
0 answers

Find if one of array elements exists within a multidimensional array

There are two arrays, $banwords with multiple words and a multidimensional one $data with two fields. I'm trying to check every array[$i][0] if there is a word from the $banwords array and if there isn't to print out the second field of…
0
votes
1 answer

How to get the complete word of the character that is obtained with stripos()? (PHP)

I can't find the documentation that indicates how to do it. I am dynamically displaying a part of a post description in the search results from my website. Example:
gomez
  • 15
  • 4
0
votes
1 answer

Why does a string in PHP not contain an empty string?

Consider the following piece of code which somehow returns false: It returns bool(false), not int(0) on PHP 7.4. I thought every string contained the empty string. So what is the cause of this behavior?
no ai please
  • 732
  • 3
  • 11
  • 24
0
votes
1 answer

PHP stripos() return only false

I'm making a filter of Badword that return true if their is a bad word in a string. but what happen is that whatever the user write the code return false. I already tried to convert the arguments of stripos() to string (just in case) but still. I…
Rzdhop
  • 37
  • 9
0
votes
1 answer

stripos(): Non-string needles warning when passing string characters

After upgrading my servers to PHP 7.3 I began seeing warnings such as: PHP Deprecated: stripos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior... in reference to the…
0
votes
2 answers

PHP Multiple 'stripos' statements

I'm trying to search within strings to find strings that contain any of a set of words, and none of another set. So far, I'm using nested stripos statements, like this: if(stripos($name, "Name", true)) { …
user1259798
  • 171
  • 1
  • 16