jjfletch Posted April 4, 2006 Share Posted April 4, 2006 The values of a field in my db looks like: [code]i.php, j.php, d.php?o=113, i.php, g.php, d.php?0=115, ... [/code]So, the following foreach statement will basically pluck the elements that start with d.php and display them. [code] preg_match_all('|d\.php\?.+?(?=,)|i', $row['longInfo'], $matchIt); foreach ($matchIt[0] as $sampX) { echo "$sampX<br />"; } [/code]The above foreach statement will generate the following:[code]// We'll call this part Main Blob d.php?o=113d.php?o=113d.php?o=113d.php?o=113d.php?o=115d.php?o=115[/code]What I actually need to display is:d.php?o=113 = 4d.php?o=115 = 2Can someone show me how to do this? I tried nesting another foreach statement, but keep receiving "Wrong parameter count" errors. Quote Link to comment https://forums.phpfreaks.com/topic/6594-grouping-counting-foreach-results/ Share on other sites More sharing options...
Barand Posted April 4, 2006 Share Posted April 4, 2006 [code]array_count_values()[/code] Quote Link to comment https://forums.phpfreaks.com/topic/6594-grouping-counting-foreach-results/#findComment-23928 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.