Having some more array trouble =\ I have this $a = explode(", ", $g->readby); $b = explode(", ", $g->view_date); foreach($a as $keys => $values){ for($i=0;$i<count($b);$i++){ if($values == $user){ $value = array_values($b); $thearray = array($values => $value); } } } print_r($thearray); PHP: I have a structure in the database like this. User: hGWMr8, hGWMr8, hGWMr8, hGWMr8, hGWMr8, hGWMr8, hGWMr8, hGWMr8, hGWMr8, yt4QYj, hGWMr8 Code (markup): Times: 1286454350, 1286454350, 1286454350, 1286363232, 1286363232, 1286363232, 1286363232, 1286479111, 1286643445, 1286802447, 1286802447 Code (markup): They are all adjacent to each other so the first in users is the timestamp for the first in times. What I'd like to be able to do is extract all the times specifically for each user, so if I want the times for hGWMr8 it'll give me 10 results rather than 11. If you think you need more information, please reply.
Below code should be helpful. $result = ''; foreach($a as $key => $value) { $result[$value][] = $b[$key]; } PHP:
Hi, you should do this via sql query instead of using arrays: SELECT t1.User,t1.Times FROM TableName t1 NATURAL JOIN (SELECT DISTINCT User FROM TableName) t2; Code (markup): Check also GROUP_CONCAT function. Regards