Re: Not easy! Best way to clean an array of arrays
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Fri, 30 May 2008 07:33:30 -0400
fluk@xxxxxxx wrote:
Hi Guys, I hope someone can help me with this, because i'm getting
crazy to find a good way to do that!
This is what I got by querying a db.
$arr1 = array("site", "description", "area1" , "activity1");
$arr2 = array("site", "description", "area1" , "activity2");
$arr3 = array("site", "description", "area2" , "activity2");
$arr4 = array("site1", "description1", "area3" , "activity2");
$my_array = array($arr1, $arr2, $arr3, $arr4);
Site and description are linked because they are in the same row of
the same table.
But every site can have 1 or more areas and every area can have 1 or
more activity.
I'd like to clean $my_array in a way I can have a compact one without
doubles
//pseudocode!
$new = array (
array('site','descr') => array (
array('area','activity')
)
);
Is it possible??
Thanks for your precious help
Francesco
Rather I think I'd make both the site name and the area indexes. You can still access the keys of those items, and it will make building your array much easier.
use something like:
$myarray = array($sitename =>
array('description' => $description,
'area' =>
array($area =>'activities' =>
array($activity))));
$sitename is the actual sitename retrieved from the database. This would give you an array similar to
[site1] = Array {
[description] = First site's description
[area] = Array {
[area1] = Array {
[0] = first activity
[1] = second activity
}
}
}
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: Not easy! Best way to clean an array of arrays
- From: fluk@xxxxxxx
- Re: Not easy! Best way to clean an array of arrays
- References:
- Not easy! Best way to clean an array of arrays
- From: fluk@xxxxxxx
- Not easy! Best way to clean an array of arrays
- Prev by Date: Not easy! Best way to clean an array of arrays
- Next by Date: Re: asp.net to PHP
- Previous by thread: Not easy! Best way to clean an array of arrays
- Next by thread: Re: Not easy! Best way to clean an array of arrays
- Index(es):
Relevant Pages
|