Tools, FAQ, Tutorials:
Splitting a String in PHP
How To Split a String into Pieces?
✍: FYIcenter.com
There are two functions you can use to split a string into pieces:
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 ".".
Â
⇒PHP Built-in Functions for Strings
⇒⇒PHP Tutorials
2016-10-13, 1245👍, 0💬
Popular Posts:
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...
How to create Hello-3.1.epub with WinRAR? I have all required files to create Hello-3.1.epub. To cre...
Where to find tutorials on how to create Your Own Functions in PHP? A collection of tutorials to ans...
How to use "xml-to-json" Azure API Policy Statement? The "xml-to-json" Policy Statement allows you t...
What is Azure API Management Publisher Portal 2017 version? Azure API Management Publisher Portal is...