Page 1 of 1

list to array

Posted: Wed May 12, 2004 8:15 am
by gurjit
hi all,

i have a list like this

1,2,3,4,5

i want to take each item in the list and display in number format on a new line....for example

1.00
2.00
3.00
4.00
5.00

how can i do this?

Posted: Wed May 12, 2004 8:19 am
by launchcode
Hi,

Code: Select all

<?php
	$numbers = "1,2,3,4,5,6";
	$number_array = explode(',', $numbers);
	foreach ($number_array as $number)
	{
		echo number_format($number, 2, '.', '') . "<br>";
	}
?>

Posted: Wed May 12, 2004 8:21 am
by gurjit
thanks launchcode, worked great. one of those days for me.

many thanks. have a great day.