0

i have an array in my PHP script,

$args=array("red","green","blue","yellow");

i want to execute a bash command who prints all values of an array.

red
green
blue
yellow

i read this question and this one, i don't want just to pass an array as an argument, i want to print each value of my array, i tried this

exec('echo ' . '"${args[@]}"');

but i got

sh: 1: Bad substitution
8
  • 3
    Why do you want to do this in bash? Commented Sep 7, 2016 at 15:53
  • i want to pass each value of this array as a parametre in bash, i use echo like an example Commented Sep 7, 2016 at 15:54
  • 1
    php array declaration can be pretty complex and multiline Commented Sep 7, 2016 at 15:56
  • @anubhava you mean i can't do that? Commented Sep 7, 2016 at 16:02
  • @GerardRoche no i read that question, i don't want just to pass array argument to bash, i want to print EACH value of my array Commented Sep 7, 2016 at 16:34

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.