Is it possible to pass an array as a command line argument to a PHP script?

前端 未结 9 888
忘掉有多难
忘掉有多难 2020-12-09 16:37

I\'m maintaining a PHP library that is responsible for fetching and storing incoming data (POST, GET, command line arguments, etc). I\'ve just fixed a bug that would not all

9条回答
  •  醉酒成梦
    2020-12-09 17:06

    The following code block will do it passing the array as a set of comma separated values:

    
    

    OUTPUT:

    php ./array_play.php 1,2,3
    
    array(3) {
      [0]=>
      string(1) "1"
      [1]=>
      string(1) "2"
      [2]=>
      string(1) "3"
    }
    

提交回复
热议问题