Wednesday, November 28, 2018

objective c - string has prefix PHP











How make an if-statement that if $mystring has the prefix "http://" then {do something}.



I've done this in objective-c like this:



if([mynsstring hasPrefix:@"http://"])

{
//Do something...
}


I don't know how to do this in PHP.
Thanks for your help in advance.


Answer



Simplest would be using substring to compare




if (substr($mystring, 0, 7) === 'http://') {
// do something
}


Remember of course to take the exact number of characters.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...