Jump to content

Convert value to array in php


mehidy

Recommended Posts

I have got the auto increment process. Now I want to convert the auto increment value in to an array. I did below but result is not okay.

I'm getting the below output
Array ( [0] => 110 )

But it should be as below.
Array ( [0] => 100 [1] => 101 [2] => 102 [3] => 103 [4] => 104 [5] => 105 [6] => 106 [7] => 107 [8] => 108 [9] => 109 [10] => 110 )

Expecting you guideline/comments to get the desired output. How to do the coding.

for($i = 100; $i <= 110; $i++) {
       echo $formattedNumber = sprintf('%03d', $i);
    //$formattedNumber1="$formattedNumber,";
    }
	echo "</br>";
	$myarray=array ();
	$myarray[] = $formattedNumber;
			print_r($myarray); 

Attached image is the result , when i run the code.

post-130823-0-31196500-1506718805_thumb.jpg

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.