0

I am passing some arguments to a PHP file from bash. Current code is working fine:

foreach($argv as $value)
{
$a= $a . "\n" . $value;
}

However I am looking for a way to start the foreach from the 3rd item of the array (which is variable so I don't know how many arguments the script will receive). Any ideas on how I can skip the first 3 elements?

Thanks!

2
  • You can use array_slice. Commented Jul 15, 2020 at 22:56
  • Works great thanks! foreach(array_slice($argv,3) as $value){ $a= $a . "\n" . $value; } Commented Jul 15, 2020 at 23:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.