hoopplaya4 Posted February 22, 2009 Share Posted February 22, 2009 Hi All, I'm trying to pass an array using exec(), but I am not able to display the array. Here's what I am using: <?php $arrayhere = array("1","2","3"); exec("php testarray.php $arrayhere > /home/public_html/logs/test.php &"); Then the "testarray.php" page has this: <?php $id = $argv[1]; foreach ($id as $value) { echo $value; } And, when I look at the results, the following error is printed: Warning: Invalid argument supplied for foreach() in /home/coachser/public_html/testarray.php on line 9 Any ideas why it wouldn't be displaying the array? Quote Link to comment Share on other sites More sharing options...
Mchl Posted February 22, 2009 Share Posted February 22, 2009 You can't pass an array through command line. You'd need to serialize it first. Quote Link to comment Share on other sites More sharing options...
hoopplaya4 Posted February 22, 2009 Author Share Posted February 22, 2009 Thanks for the reply. So, now, when attempting to serialize, for some reason, the exec() does not even take place. This is my new code: <?php $arrayhere = array("1","2","3"); $newarray = serialize($arrayhere); exec("php testarray.php $newarray > /home/coachser/public_html/logs/newtest.php &"); It's not even creating the "newtest.php" file. But, I found that when I remove the $newarray from the exec("php testarray.php... portion, then it creates the "newtest.php" file. Any idea what I'm doing wrong here? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.