title: php loop through json array
body: <p>I have a json string like this:</p>
  
  <pre><code>$fields_string = '
  {"fields":
     {"customers":[{"name":"john","id":"d1"},
                   {"name":"mike","id":"d2"},
                   {"name":"andrew","id":"d3"},
                   {"name":"peter","id":"d4"}]
     }
  }'
  </code></pre>
  
  <p>How can I print each name? I will use them later in a html select options, I know how to do that. But I couldn't get the string out. 
  Here are something I tried:</p>
  
  <pre><code>$obj = json_decode($fields_string);
  $fields_detail = $obj-?{"fields"}-&gt;{"customers"};
  </code></pre>
  
  <p>at this point, I am able to print the customer array out by <code>echo json_encode($fields_detail)</code>, but before that, I want to get the name break down using <code>foreach</code>. I tried several times, it didn't work. Can anyone help please. </p>
  
  <p>Thanks!</p>