Jump to content

PLEASE PLEASE assist me with this stupid code (array related)


Guest upirate

Recommended Posts

Guest upirate

I am trying to put stuff in a 2d array:

 

$manu_array=array();

 

foreach ( $manu_grouping["matches"] as $doc => $docinfo )

{

$manuname=get_manf($docinfo['attrs']['mfid']);

 

 

$mnfcount=$docinfo['attrs']['@count'];

 

$manu_array[] = "[(".$mnfcount."), (".$manuname.")]";

 

}

 

 

 

How do I display it so I can get back manuname and mnfcount ?

 

 

Print_R is giving me output like: 

 

  [2] => [(97), (tamron)]

    [3] => [(961), (canon computer sys inc)]

    [4] => [(94), (celldome)]

    [5] => [(93), (nukote international)]

    [6] => [(9), (university press of the pacific)]

    [7] => [(9), (university press of america)]

 

For example inindex 6 I only need 9 and university press of pacific

 

 

HELP

 

yeah, you are getting the parentheses in your output because you are putting them in when you define your data in your last line.

 

also, i see you have only one item that includes both values. you could alternately put each value in its own item in a 3d array. just change your last line like this:

 

$manu_array[] = array($mnfcount, $manuname);

 

this could help you out later by keeping the values separated.


$manu_array[] = array($mnfcount, $manuname);
/*output array[0]=>array(
                                 [0]=>$mnfcount
                                 [1]=>$manuname
                                  )
*/

 

 


$manu_array[] = $mnfcount. ", ". $manuname;
/*
output array[0]=>$mnfcount, $manuname
*/

 

 

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.