How do I check if a string contains another string in Objective-C?

NSString *string = @”hello bla bla”; if ([string rangeOfString:@”bla”].location == NSNotFound) { NSLog(@”string does not contain bla”); } else { NSLog(@”string contains bla!”); } The key is noticing that rangeOfString: returns an NSRange struct, and the documentation says that it returns the struct {NSNotFound, 0} if the “haystack” does not contain the “needle”. And if … Read more

How do I check if a string contains a specific word?

Now with PHP 8 you can do this using str_contains: if (str_contains(‘How are you’, ‘are’)) { echo ‘true’; } RFC Before PHP 8 You can use the strpos() function which is used to find the occurrence of one string inside another one: $a=”How are you?”; if (strpos($a, ‘are’) !== false) { echo ‘true’; } Note … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)