Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

help with arraya

1 view
Skip to first unread message

Dave

unread,
Jun 21, 2009, 4:47:00 PM6/21/09
to
I have 2 arrays $percent and $jobs
Array
(
[Percent] => Array
(
[0] => 28
[1] => 39
[2] => 17
[3] => 28
[4] => 23
)
)
and

Array
(
[Jobs] => Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
)
)

How can I combine them together based on the key to create

Array
(
[0] => Array
(
[Job] => 3
[Percent] => 28

)
[1] => Array
(
[Job] => 4
[Percent] => 39

)
[2] => Array
(
[Job] => 5
[Percent] => 17

)
........ and so on for each
)

the Big H

unread,
Oct 19, 2009, 2:11:16 AM10/19/09
to
try:

<?
// clean it up
$jobs = $yourjobs['Jobs'];
$pcts = $yourpcts['Percent'];

// make a counter
$i=0;

// loop thru jobs array
foreach($jobs as $value)
{
$newarray[] = array("Job"=>$value,
"Percent"=>$pcts[$i]);

++$i; // increment $i
}


// debug
?><pre><?
print_r($newarray[]);
?></pre><?

?>

I know dirty 8 )


--
------------------------------------
The Developer Network
http://thedevnet.com

0 new messages