lilyyan
asked on
why array_push doesn't work
hello:
why array_push() doesn't work for the following code?
thanks for your reply!
why array_push() doesn't work for the following code?
thanks for your reply!
$projLocation=array();
foreach ($pg[1] as $loc){
$elem= $pg[0][0]." - ".$loc; // this does print the info.
$projLocation = array_push($projLocation, $elem);
}
echo "loc=".$projLocation[0]; //this print nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try to echo $elem and $projLocation to check value
ASKER
well, only this one worked:(@cxr)
$projLocation[] = $elem;
maybe it's because $projLocation is an empty array?
$projLocation[] = $elem;
maybe it's because $projLocation is an empty array?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.