Click to See Complete Forum and Search --> : Why do I suck at 2d arrays? Plz help :(


tgrk35
06-25-2007, 11:37 AM
Ok, here's my script:

$bpcaccounts = array();
for($i = 0; $i < count($_POST['bpc']); $i++){
if($_POST['bpc'][$i]['bpcname'] != '' && $_POST['bpc'][$i]['bpcnum'] != '' && $_POST['bpc'][$i]['bpcexp'] != ''){
$bpcaccounts .= array('bpcname' => $_POST['bpc'][$i]['bpcname'],'bpcnum' => $_POST['bpc'][$i]['bpcnum'],'bpcexp' => $_POST['bpc'][$i]['bpcexp']);
}
}

Basically...it's messed up. I just want to pull the values from $_POST['bpc'] that aren't blank. $_POST['bpc'] is a 2d array (basically). I can get it to pull only the ones I want (the ones that aren't blank), but then I try to put it in a new array ($bpcaccounts) and it messes up. If I do a print_r on $bpcaccounts, I get this:

ArrayArrayArray

Anyway, I know the problem probably lies in my creation of the $bpcaccounts array.

Does anyone have any ideas? I'm VERY confused and I've been working on this for nearly 2 weeks now...which is sad, honestly.

Anyway, all help I can get is much appreciated.

Thanks :)
Will

JDM71488
06-25-2007, 12:38 PM
See if this works:

foreach($_POST['bpc'] as $bpc)
{
if($bpc['bpcname'] != '' && $bpc['bpcum'] != '' && $bpc != '')
{
$goodBPCs[] = $bpc;
}
}

tgrk35
06-25-2007, 12:49 PM
You pretty much just saved my ass.

Thanks A LOT.

:D