Tutorial by Examples

explode and strstr are simpler methods to get substrings by separators. A string containing several parts of text that are separated by a common character can be split into parts with the explode function. $fruits = "apple,pear,grapefruit,cherry"; print_r(explode(",",$fruits))...
strpos can be understood as the number of bytes in the haystack before the first occurrence of the needle. var_dump(strpos("haystack", "hay")); // int(0) var_dump(strpos("haystack", "stack")); // int(3) var_dump(strpos("haystack", "stackoverf...
preg_match can be used to parse string using regular expression. The parts of expression enclosed in parenthesis are called subpatterns and with them you can pick individual parts of the string. $str = "<a href=\"http://example.org\">My Link</a>"; $pattern = "/...
Substring returns the portion of string specified by the start and length parameters. var_dump(substr("Boo", 1)); // string(2) "oo" If there is a possibility of meeting multi-byte character strings, then it would be safer to use mb_substr. $cake = "cakeæøå"; var_d...

Page 1 of 1