Jump to content

Archived

This topic is now archived and is closed to further replies.

jjfletch

Grouping / counting foreach results

Recommended Posts

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=113
d.php?o=113
d.php?o=113
d.php?o=113
d.php?o=115
d.php?o=115
[/code]


What I actually need to display is:

d.php?o=113 = 4
d.php?o=115 = 2

Can someone show me how to do this? I tried nesting another foreach statement, but keep receiving "Wrong parameter count" errors.


Share this post


Link to post
Share on other sites

×

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.