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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.