seperate numbers

Posted on 2009-06-29
Last Modified: 2012-05-07
Given somthing like: 859034, 482309, 7432890, 483902
Seperate it out as so:

$1 = "859034";
$2= "482309";

And so on ...
Question by:happpy36
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 19

Expert Comment

ID: 24741959
can you use an array?

$data = "859034, 482309, 7432890, 483902"

$my_array = explode(", ",$data)

Author Comment

ID: 24741996
code that takes the first number in the list 859034, 482309, 7432890, 483902 and then stores it in the
variable, $number, and then loops back and stores the second number, 482309, in $number and so on
would work perfect for me.

Expert Comment

ID: 24742028
Are your numbers are as a string

$nums = "859034, 482309, 7432890, 483902"

or arrays

$nums = array(859034, 482309, 7432890, 483902);

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Accepted Solution

Jagarm earned 200 total points
ID: 24742041
Is the following you are looking for?
//using array
$nums = array(859034, 482309, 7432890, 483902);
foreach ($nums as $number) {
	echo "$number<br />";
//using string
$nums = "859034, 482309, 7432890, 483902";
$nums = split(",",$nums);	//splitted by comma
foreach ($nums as $number) {
	echo "$number<br />";

Open in new window

LVL 27

Assisted Solution

by:Cornelia Yoder
Cornelia Yoder earned 190 total points
ID: 24742096
This echoes out the following:

$nums = '859034, 482309, 7432890, 483902';
$array = explode(", ",$nums);
for ($i=0;$i<count($array);$i++)
    $number = $array[$i];
    echo $number;
    echo "<br />";

Open in new window

LVL 14

Assisted Solution

by:Ionut A. Tudor
Ionut A. Tudor earned 110 total points
ID: 24742180
maybe you want them to be stored for further references, see below
$numbers = "859034, 482309, 7432890, 483902";
$numbers_array = split(", ",$numbers);
extract($numbers_array, EXTR_PREFIX_ALL, "number");
echo $number_0;
echo "\n<br>";
echo $number_1;
echo "\n<br>";
echo $number_2;
echo "\n<br>";
echo $number_3;

Open in new window


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question