Skip to content
Advertisement

Tag: strpos

Remove characters from beginning and end string

I want to ouput only MYID from URL. What I did so far: output: https://whatever.expamle.com/display/MYID ouput: MYID?out=1234567890?Browser=0?OS=1 How can I combine this? Thanks. Answer When the string is always a Uniform Resource Locator (URL), like you present it in your question, given the following string: you can benefit from parsing it first: and then making use of the fact that

PHP Regex Match Specific Pattern between Quotes

I have strings with the following pattern: adfadfadfadfadfadfafdadfa”externalId”:”UCEjBDKfrqQI4TgzT9YLNT8g”afadfadfafadfdaffzfzfzxf Basically, I need to find “externalId” and extract it’s value in between the quotes that follow. The length of the value can change so it needs to be everything inside the two quotes. In this case the desired outcome is to return: Here’s what I have so far: I tried Advanced HTML

Check if one of multiple words exists in the string?

I have a string like this: I want to check it for these words: it, test. I want to it returns true if there is at least one of those words in the string. Here is what I did: (though it does not work) How can I do that? Answer Simply checking using preg_match(), you can add many different words

Using an array as needles in strpos

How do you use the strpos for an array of needles when searching a string? For example: $find_letters = array(‘a’, ‘c’, ‘d’); $string = ‘abcdefg’; if(strpos($string, $find_letters) !== false) { …

Advertisement