Solved

seperate numbers

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

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

And so on ...
0
Comment
Question by:happpy36
6 Comments
 
LVL 19

Expert Comment

by:Michael701
ID: 24741959
can you use an array?

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

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

Author Comment

by:happpy36
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.
0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24742028
Are your numbers are as a string

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

or arrays

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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Accepted Solution

by:
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

0
 
LVL 27

Assisted Solution

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

859034
482309
7432890
483902
<?php
 

$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

0
 
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
<?php

$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

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: 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.

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now