maybe try this:

$str = 'one,two,three,four'; 
$newstr = explode(',',n = 'str'; //sufix
$c=1; //counter
foreach($newstr as $value){
    n.$c; //assign vars
    $value; //assign value for var
    $c++;
}

var_dump($str1);
var_dump($str2);
var_dump($str3);
var_dump($str4);

response:

string 'one' (length=3)    
string 'two' (length=3)    
string 'three' (length=5)  
string 'four' (length=4)
Answer from miglio on Stack Overflow
🌐
PHP
php.net › manual › en › function.explode.php
PHP: explode - Manual
If separator is an empty string (""), explode() throws a ValueError. If separator contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned. 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
The explode() function breaks a string into an array. Note: This function is binary-safe. ... <?php $str = 'one,two,three,four'; // zero limit print_r(explode(',',$str,0)); // positive limit print_r(explode(',',$str,2)); // negative limit ...
Discussions

Php Explode string and out put each string without showing array - Stack Overflow
I have something saved in my database like this PHP,HTML,CSS,SQL,JQUERY,.... More can stile show or it might end up being 2 or 1 depending on how may saved for current viewing post. Now i need to More on stackoverflow.com
🌐 stackoverflow.com
If you explode a string and said string does not contain the ...
So I'm getting a section of the url with php. This section may or may not have trailing '?' values. So for example : I'm exploding the url : stackoverflow.com/questions and I want to get questions ... More on stackoverflow.com
🌐 stackoverflow.com
Explode PHP string by new line - Stack Overflow
If you're not sure which type of EOL you have, run a str_replace before your explode, replacing "\n\r" with "\n". ... Single quotes in PHP mean "don't parse this string". That means your control characters aren't being parsed, they're being taken as literal (not a line break and a carriage ... More on stackoverflow.com
🌐 stackoverflow.com
Lightweight replacement for PHP explode function
Doubts to use windows for this task, maybe it's better to iterate byte-by-byte and collect data by contains or starts_with function for performance reasons? Shortly, my input request looks like that: header\r\nsome data 1\r\nsome data 2 In PHP, I've simply used explode function, now thinking ... More on users.rust-lang.org
🌐 users.rust-lang.org
1
0
January 12, 2025
🌐
Zero To Mastery
zerotomastery.io › blog › php-explode-beginners-guide
Beginner's Guide to PHP explode() Function (With Code Examples!) | Zero To Mastery
May 13, 2024 - However, the delimiter you choose for the explode() function can be any character or sequence of characters. It’s completely up to you what you decide to use, and depends on what you're trying to achieve with your script. ... <?php $inputString = "The quick brown fox jumps over the lazy dog"; print_r(explode(" ", $inputString)); ?>
🌐
Afterhoursprogramming
afterhoursprogramming.com › tutorials › php › string-implode-and-explode
String Implode & Explode - PHP
Inside that function, we have our explode function. First, we say that we want to separate everything by spaces, " ", and we want to break up $myString. We could pass anything we want into the first parameter, and PHP will find any matches and explode the parts around it into an array.
Find elsewhere
🌐
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).
🌐
ReqBin
reqbin.com › code › php › bnk8kgym › php-split-string-example
How do I split a string in PHP?
The explode() is a built-in function that splits strings into arrays. The function takes three parameters: an input string to split, a delimiter, and, optionally, a limit on the number of ...
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-explode-function
PHP explode() Function - GeeksforGeeks
June 24, 2025 - The explode() function in PHP is used to split a string into an array based on a specified delimiter. This function is commonly used when you need to break down a string into individual parts.
🌐
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 ...
🌐
PHP Architect
phparch.com › home › php explode explained
PHP Explode Explained | PHP Architect
November 19, 2025 - explode()` is a handy PHP function that helps us split strings into smaller parts. Here’s how it works, what it’s used for, and what you can do with it.
🌐
Functions-Online
functions-online.com › explode.html
test explode online - PHP string functions - functions-online
Test and run explode online in your browser. Returns an array of strings, each of which is a substring of $string formed by splitting it on bound
🌐
SitePoint
sitepoint.com › php
PHP explode() white space issue - PHP - SitePoint Forums | Web Development & Design Community
October 8, 2006 - I’ve got an issue with spacing in strings when I do explode(); I’m sure there is an easy fix for this The user enters a string into a form like this: one, two, three, four, five, six OR like this one,two,three,four,five,six sometimes they enter spaces after the commas, sometimes they don’t. that is up to them, but it can screw up my explosion That string is saved as $keywords.
🌐
Simplilearn
simplilearn.com › home › resources › software development › explode in php function: everything you need to know
Explode in PHP Function: Everything You Need to Know
November 18, 2025 - Explode in PHP is one of the built-in functions. Learn all about explode function ✓ its uses ✓ parameters ✓ syntax, and much more in this tutorial. Start now!
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
OnlinePHP
onlinephp.io › explode
explode - Online Tool
PHP Functions · String Manipulation · explode · Execute explode with this online tool explode() - Split a string by a string · Explode Online Tool · Manual · Code Examples · Explode Online Tool · Manual · Code Examples · addcslashes ...
🌐
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