Its
prototype follows:
array split(string pattern, string string [, int limit])
The optional input parameter limit is used to specify the number of elements into
which the string should be divided, starting from the left end of the string and working
rightward. In cases where the pattern is an alphabetical character, split() is case
sensitive. Here??™s how you would use split() to break a string into pieces based on
occurrences of horizontal tabs and newline characters:
$text = "this is\tsome text that\nwe might like to parse.";
print_r(split("[\n\t]",$text));
?>
CHAPTER 9 ?– S TRINGS AND REGULAR EXPRESS IONS 239
This returns the following:
Array ( [0] => this is [1] => some text that [2] => we might like to parse. )
Splitting a String into Various Elements Based on a Case-Insensitive Pattern
The spliti() function operates exactly in the same manner as its sibling, split(),
except that its pattern is treated in a case-insensitive fashion. Its prototype follows:
array spliti(string pattern, string string [, int limit])
Accommodating Products Supporting Solely Case-Sensitive Regular Expressions
The sql_regcase() function converts each character in a string into a bracketed expression
containing two characters. If the character is alphabetical, the bracket will contain
both forms; otherwise, the original character will be left unchanged. Its prototype
follows:
string sql_regcase(string string)
You might use this function as a workaround when using PHP applications to talk
to other applications that support only case-sensitive regular expressions.
Pages:
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317