🌐
PHP
php.net › manual › en › function.explode.php
PHP: explode - Manual
If separator values appear at the start or end of string, said values will be added as an empty array value either in the first or last position of the returned array respectively. ... <?php // Example 1 $pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); echo $pieces[0], PHP_EOL; // piece1 echo $pieces[1], PHP_EOL; // piece2 // Example 2 $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user, PHP_EOL; // foo echo $pass, PHP_EOL; // * ?>
🌐
W3Schools
w3schools.com › php › func_string_explode.asp
PHP explode() Function
<?php $str = "Hello world. It's a beautiful day."; print_r (explode(" ",$str)); ?> Try it Yourself » · The explode() function breaks a string into an array.
Discussions

php - Explode to array and print each element as list item - Stack Overflow
I have a set of numbers in a table field in database, the numbers are separated by comma ','. I am trying to do the following: Step 1. : SELECT set of numbers from database and explode it to array... More on stackoverflow.com
🌐 stackoverflow.com
php - Explode each values of Array element - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I want to explode each element of an array and return a new array using array_map, so that I can avoid using loop, and creating extra function to call back. More on stackoverflow.com
🌐 stackoverflow.com
PHP explode array then loop through values and output to variable - Stack Overflow
What it takes to be a player in the international AI... ... Help Shape the 2026 Developer Survey! ... 2 Split a delimited string and create single-element associative rows from the values with a static key · 0 PHP loop through exploded values to populate an array More on stackoverflow.com
🌐 stackoverflow.com
php - Exploding by Array of Delimiters - Stack Overflow
Is there any way to explode() using an array of delimiters? PHP Manual: array explode ( string $delimiter , string $string [, int $limit ] ) Instead of using string $delimiter is there any way to... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Zero To Mastery
zerotomastery.io › blog › php-explode-beginners-guide
Beginner's Guide to PHP explode() Function (With Code Examples!) | Zero To Mastery
As I mentioned earlier, the explode() function can also take an optional third argument, limit, so let’s take a look at this in action. If limit is set, the returned array will contain a maximum of limit elements with the last element containing the rest of the string. ... <?php $inputString = "apple, banana, cherry, date, elderberry"; print_r(explode(", ", $inputString, 2)); ?>
🌐
freeCodeCamp
freecodecamp.org › news › php-explode-how-to-split-a-string-into-an-array
PHP Explode – How to Split a String into an Array
October 17, 2022 - The PHP explode() function converts a string to an array. Each of the characters in the string is given an index that starts from 0. Like the built-in implode() function, the explode function does not modify the data (string).
🌐
PHP Tutorial
phptutorial.net › home › php tutorial › php explode
PHP explode(): Split a String by a Separator into an Array of Strings
April 7, 2025 - The PHP explode() function returns an array of strings by splitting a string by a separator. The following shows the syntax of the explode() function: explode ( string $separator , string $string , int $limit = PHP_INT_MAX ) : arrayCode language: ...
🌐
Codecademy
codecademy.com › docs › php › string functions › explode()
PHP | String Functions | explode() | Codecademy
June 27, 2025 - The explode() function is a built-in PHP string function that splits a string into an array based on a specified delimiter. It takes a string and breaks it apart at every occurrence of the delimiter, returning an array containing the resulting ...
🌐
w3resource
w3resource.com › php › function-reference › explode.php
PHP explode() function - w3resource
October 3, 2024 - <?php $class_list='V,VI,VII,VIII,IX,X'; $classes=explode(",",$class_list); print_r($classes); ?> Output : Array ( [0] => V [1] => VI [2] => VII [3] => VIII [4] => IX [5] => X ) View the example in the browser · See also · PHP Function Reference · Previous: crypt Next: fprintf  ·
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-explode-function
PHP explode() Function - GeeksforGeeks
June 24, 2025 - ... <?php $str = "Riya,Rimjhim,Ayushi"; // Define a string with comma-separated names // Use explode() to split the string by the comma delimiter, limiting to 3 parts $result = explode(",", $str, 3); // Print the resulting array print_r($result); ...
Find elsewhere
🌐
Flexiple
flexiple.com › php › php-explode
PHP explode: Splitting strings into arrays - Flexiple
March 9, 2022 - PHP explode() is a built-in function that is used to split a string into a string array.
🌐
Reintech
reintech.io › blog › comprehensive-guide-php-explode-function
A Comprehensive Guide to the PHP `explode()` Function
... Positive value: Returns at ... case involves splitting comma-separated values: $languages = "PHP, JavaScript, Python, Ruby"; $languageArray = explode(", ", $languages); print_r($languageArray); // Output: // Array // ( // [0] => PHP // [1] => JavaScript // [2] => Python ...
🌐
3D Bay
clouddevs.com › home › php guides › unpacking php’s explode() function: a complete guide
Unpacking PHP's explode() Function: A Complete Guide
December 13, 2023 - As you can see, explode() has successfully split the string into an array, with each element corresponding to a fruit. The delimiter is a crucial element when using explode(). It determines how the input string should be divided. Let’s explore different scenarios involving delimiters. In most cases, you’ll use single characters as delimiters. Here’s an example: php $input = "one,two,three,four,five"; $numbers = explode(",", $input); print_r($numbers);
🌐
Koladechris
koladechris.com › blog › php-implode-and-explode
PHP Implode and Explode
Learn how PHP implode() concatenates arrays into strings, and how explode() splits strings into arrays
🌐
Scaler
scaler.com › home › topics › php explode() function
PHP explode() Function - Scaler Topics
March 18, 2024 - This function is commonly used ... addresses, or URLs. In PHP, explode is a built-in function that allows you to split a string into an array, based on a specified delimiter....
🌐
MuneebDev
muneebdev.com › php-explode
PHP Explode Function Explained: Examples, Best Practices, and Common Use Cases - MuneebDev
September 6, 2024 - The PHP explode() function is used to split a string into an array of substrings, based on a specified delimiter.