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

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer