I'm trying to get a well-better formated list of information.
Basically what I have right now is a multi dimensional array that has multiple entries in it with different data.
If I would do foreach $bigarray, I would get something like this:
array(
"id" => 1,
"company" => "bar",
"advertisment" => "Selling X",
"user_id" => "200",
"uri" => "bbbbbbxa"
);
array(
"id" => 2,
"company" => "bar",
"advertisment" => "Selling ABC",
"user_id" => "200",
"uri" => "xxxaaaa"
);
array(
"id" => 3,
"company" => "CROMUS",
"advertisment" => "Selling BBB",
"user_id" => "222",
"uri" => "bsaxxaa"
);
** notice the same user_id and company name **
** I want a unique list of companies with ads corresponding to it **
From the above I would get 3 'squares' of data like this:
- Company Name
- Advertisment Title
================
- Same Company Name
- Same advertisment title
================
- Different Company Name
- Different advertisment title
=========================
but I would want to get:
=========================
- Company Name
- first advertisment title
- second advertisment title
- ** so on if any other entries with same user_id are found **
=========================
- Different Company Name
- Different Advertisment
=========================
So basically I would want array 1 to add somehow to array 0 so when I echo in the foreach($bigarray as $post), I go something like
echo $post['advertisment'].' '.$post['uri']
echo $post['advertisment_2'].' '.$post['uri2']
Note: I might have more than 2 values , I might have 6 ads on the same company and I basically want to organise them by the id (the top one would be the newest)
Until now I did something like this just to realise i took the wrong approach:
foreach($latest->posts as $key => $post) {
if(in_array($post->user_id,$iduri)){
array_push($iduri, $post->user_id);
}
if(in_array($post->user_id,$iduri)) {
array_push($cuie,$post->title);
array_push($urix,$post->uri);
} else {
for ($i = 0; $i <= count($cuie); $i++) {
echo $cuie[i];
echo $urix[i];
}
} // end if in array
} //end foreach