Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Split a String into an Array of Substring
How To Split a String into an Array of Substring? - PHP Script Tips - PHP Built-in Functions for Arrays
✍: FYIcenter.com
There are two functions you can use to split a string into an Array of Substring:
Both functions will use the given criteria, substring or pattern, to find the splitting points in the string, break the string into pieces at the splitting points, and return the pieces in an array. Here is a PHP script on how to use explode() and split():
<?php
$list = explode("_","php_strting_function.html");
print("explode() returns:\n");
print_r($list);
$list = split("[_.]","php_strting_function.html");
print("split() returns:\n");
print_r($list);
?>
This script will print:
explode() returns:
Array
(
[0] => php
[1] => strting
[2] => function.html
)
split() returns:
Array
(
[0] => php
[1] => strting
[2] => function
[3] => html
)
The output shows you the power of power of split() with a regular expression pattern as the splitting criteria. Pattern "[_.]" tells split() to split whenever there is a "_" or ".".
2007-04-22, 5451👍, 0💬
Popular Posts:
How Are Vertical Margins between Two Block Elements Collapsed? - CSS Tutorials - Understanding Multi...
How To Write a Query with a Right Outer Join? - Oracle DBA FAQ - Understanding SQL SELECT Query Stat...
Assuming that the structure of a table shows two columns like this: --------+------------+-- ----+---...
How To Define a Data Source Name (DSN) in ODBC Manager? - Oracle DBA FAQ - ODBC Drivers, DSN Configu...
Is Session_End event supported in all session modes ? Session_End event occurs only in “Inproc mode”...