Guest upirate Posted February 28, 2007 Share Posted February 28, 2007 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 Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/ Share on other sites More sharing options...
itsmeArry Posted February 28, 2007 Share Posted February 28, 2007 did u mean like this [6] => [9, university press of the pacific] instead of [6] => [(9), (university press of the pacific)] Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196107 Share on other sites More sharing options...
Guest upirate Posted February 28, 2007 Share Posted February 28, 2007 yes!! Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196110 Share on other sites More sharing options...
Orio Posted February 28, 2007 Share Posted February 28, 2007 So change it to this... $manu_array[] = "[".$mnfcount.", ".$manuname."]"; Orio. Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196118 Share on other sites More sharing options...
obsidian Posted February 28, 2007 Share Posted February 28, 2007 Or, just put it all within your double quotes: <?php $manu_array[] = "[$mnfcount, $manuname]"; ?> Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196212 Share on other sites More sharing options...
bulletseed Posted February 28, 2007 Share Posted February 28, 2007 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. Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196224 Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 $manu_array[] = array($mnfcount, $manuname); /*output array[0]=>array( [0]=>$mnfcount [1]=>$manuname ) */ $manu_array[] = $mnfcount. ", ". $manuname; /* output array[0]=>$mnfcount, $manuname */ Link to comment https://forums.phpfreaks.com/topic/40526-please-please-assist-me-with-this-stupid-code-array-related/#findComment-196745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.