I am not sure if this is possible, but I need to make a dirty hack.
Assume I am invoking php from cli
php script.php one two
then in script.php I am doing something with two parameter, and then I would like to remove it, so the third party code that is included later on thought, that the initial command was
php script.php one
I tried unset($argv[2]) and unset($GLOBALS['argv'][2]) but this does not work. Is it after all possible what I am trying to do ?
UPDATE:
Does not work = I get exception from third party code “Too many arguments”
UPDATE: of course it should be argv[1], but it is a typo only in this question, not in the actual problem. Please assume I have written argv[1] 🙂
Manipulating $argc and $argv from within a php script is not possible AFAIK. This is because the values are not part of the script itself, but defined in the calling scope.
As an alternative you could copy the array, pop the last argument and call the “third party code” by using exec() or system() and handing over the reduced copy.