Web host 4 life - 144Part IPHP: The BasicsTable 8-1: Simple Inspection, Comparison,
Monday, September 10th, 2007144Part IPHP: The BasicsTable 8-1: Simple Inspection, Comparison, and Searching FunctionsFunctionBehaviorstrlen()Takes a single string argument and returns its length as an integer. strpos()Takes two string arguments: a string to search, and the string being searchedfor. Returns the (0-based) position of the beginning of the first instance of thestring if found, and a false value otherwise. It also takes a third optionalinteger argument, specifying the position at which the search should begin. strrpos()Like strpos(), except that it searches backward from the end of the string, rather than forward from the beginning. The search string must only be onecharacter long, and there is no optional position argument. strcmp()Takes two strings as arguments and returns 0 if the strings are exactlyequivalent. If strcmp()encounters a difference, it returns a negativenumber if the first different byte is a smaller ASCII value in the first string, anda positive number if the smaller byte is found in the second string. strcasecmp()Identical to strcmp(), except that lowercase and uppercase versions of thesame letter compare as equal. strstr()Searches its first string argument to see if its second string argument iscontained in it. Returns the substring of the first string that starts with the firstinstance of the second argument, if any is found otherwise, it returns false. strchr()Identical to strstr(). stristr()Identical to strstr()except that the comparison is case independent. Substring selectionMany of PHP s string functions have to do with slicing and dicing your strings. By slicing,wemean choosing a portion of a string; by dicing,we mean selectively modifying a string. Keepin mind that (most of the time) even dicing functions do not change the string you started outwith. Usually, such functions return a modified copy, leaving the original argument intact. The most basic way to choose a portion of a string is the substr()function, which returns anew string that is a subsequence of the old one. As arguments, it takes a string (that the sub- string will be selected from), an integer (the position at which the desired substring starts), and an optional third integer argument that is the length of the desired substring. If no thirdargument is given, the substring is assumed to continue until the end. (Remember that, aswith all PHP arguments that deal with numerical string positions, the numbering starts with 0rather than 1.) For example, the statement: echo(substr( Take what you need, and leave the rest behind , 23)); prints the string leavetherestbehind, whereas the statement: echo(substr( Take what you need, and leave the rest behind , 5, 13)); prints whatyouneed a 13-character string starting at (0-based) position 5.10
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.