Can I Use Array_push On A SESSION Array In Php?
Answer :
Yes, you can. But First argument should be an array.
So, you must do it this way
$_SESSION['names'] = array(); array_push($_SESSION['names'],$name);
Personally I never use array_push as I see no sense in this function. And I just use
$_SESSION['names'][] = $name;
Try with
if (!isset($_SESSION['names'])) { $_SESSION['names'] = array(); } array_push($_SESSION['names'],$name);
Comments
Post a Comment