Link to home
Start Free TrialLog in
Avatar of lilyyan
lilyyan

asked on

why array_push doesn't work

hello:

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Roger Baklund
Roger Baklund
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
try to echo $elem and $projLocation to check value
Avatar of lilyyan
lilyyan

ASKER

well, only this one worked:(@cxr)
$projLocation[] = $elem;

maybe it's because $projLocation is an empty array?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial