I want to pass an array from command line to php as:
c:\<path>\php.exe somefile.php --filter array{['name']=>"lion",['category']=>array{['teeth']=>'long_teeth',['height']=>'short'}}
and now in code I want variable filter as an array as I passed through command line like:
$opt['filter'] = array {
['name']=>"lion",
['category']=>
array{
['teeth']=>'long_teeth',
['height']=>'short'
}
}
But the problem is passed argument becomes string and I am not able to parse it to array. I am using getopt() function to get filter as an attribute to array variable $opt like:
$shortopts = "abc"; // These options do not accept values
$longopts = array(
"filter:", // Required value
);<br>
$opt = getopt($shortopts, $longopts);
actually whole scenario is to take a variable as an array or string or a boolean value and pass it to another php script as it is and that script I am calling through exec function like:
exec(c:\<path>\php.exe myphpscript.php --filter $array_variable );
and then in myphpscript.php, I want to use $array_variable
as it was in earlier script so that I can use it as it was.