Jump to content

[SOLVED] Arrays ?


ainoy31

Recommended Posts

Hello-

 

I believe my brain is fryed and seem to not be able to think this through.  I need help with the following.

 

I have two dynamic arrays.  The first array will contain the commodity name such as $comm = Array ( [0] => X [1] => Y [2] => [3] => ... and so forth).  The second array contains an unique number to each commodity such as $htsus = Array ( [0] => 12345 [1] => 6789 [2] => ... and so forth).

 

I need to get the format to display as follows:

Commodity: X HTSUS: 12345

Commodity: Y HTSUS: 6789

.....

I have tried using the foreach function but no luck.

 

foreach($comm as $var)
{
echo "Commodity: " . $var . ' ';
             foreach($htsus as $data)
             {
                     echo "HTSUS: " . $data <br />";
             }

}

 

Much appreciation.. AM

Link to comment
https://forums.phpfreaks.com/topic/81732-solved-arrays/
Share on other sites

You could use two dimensions like:

$comm = array(array('X',12345), array('Y',6789));

Or even like this if you want to name the keys:

$comm = array(array("name" => 'x',"uniqid" => 12345), array("name" => 'Y',"uniqid" => 6789));

 

I think it would be easier. Do a print_r($comm) to visualize it.

Link to comment
https://forums.phpfreaks.com/topic/81732-solved-arrays/#findComment-415090
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.