title: Manipulating an array (printed by php-cli) in shell script
body: <p>I am a newbie with shell scripts and I learnt a lot today.
  This is an extension to this question <a href="https://stackoverflow.com/questions/4376695/assigning-values-printed-by-php-cli-to-shell-variables">Assigning values printed by PHP CLI to shell variables</a></p>
  
  <p>I got the solution to read a variable in my shell script. Now how to manipulate an array? If I prepare an array in my PHP code and print it, and echo in my shell, it displays Array. How to access that array in the shell script? I tried the solution given in <a href="https://stackoverflow.com/questions/2352530/how-to-manipulate-array-in-shell-script/2353298#2353298">how to manipulate array in shell script</a></p>
  
  <p><strong>With the following code:-</strong><br>
  <em>PHP code</em>  </p>
  
  <pre><code>$neededConstants = array("BASE_PATH","db_host","db_name","db_user","db_pass");
  
  $associativeArray = array();
  foreach($neededConstants as $each)
  {
      $associativeArray[$each] = constant($each);
  }
  
  print $associativeArray;
  </code></pre>
  
  <p><em>Shell code</em></p>
  
  <pre><code>function getConfigVals()
  {
      php $PWD'/developer.php'
  }
  
  
  
  
  cd ..
  PROJECT_ROOT=$PWD
  cd developer
  
  # func1 parameters: a b
  result=$(getConfigVals)
  
  for((cnt=0;cnt&lt;${#result};cnt++))
  do
      echo ${result[$cnt]}" - "$cnt
  done
  </code></pre>
  
  <p>I get this output:-</p>
  
  <pre><code>Array - 0
   - 1
   - 2
   - 3
   - 4
  </code></pre>
  
  <p>Whereas I want to get this:-</p>
  
  <pre><code>Array
        BASE_PATH - /path/to/project
        db_host - localhost 
        db_name - database
        db_user - root 
        db_pass - root
  </code></pre>