title: Put JSON data into html form input checkbox with PHP
body: <p>I want to put json data into html form input checkbox with laravel blade.</p>
  
  <p>I have multiple input checkbox values as <code>test[]</code>, </p>
  
  <p>Then I try use <code>htmlspecialchars</code> to print values into input.</p>
  
  <p>If my frontend check this input, backend use print_r is like this</p>
  
  <pre><code>Array
  (
      [0] =&gt; {"value1":"tool_ad_id","value2":"\u65e5\u4ed8"}
      [1] =&gt; {"value1":"ad_group1","value2":"\u30c4\u30fc\u30eb\u5e83\u544aID"}
  )
  </code></pre>
  
  <p>but I use <code>return $request-&gt;test['0']['value1'];</code>  can't get a value.</p>
  
  <p>I want to get 'value1' and 'value2'.</p>
  
  <p><strong>PHP Laravel</strong></p>
  
  <pre><code>@foreach($as as $key =&gt; $value)
        &lt;div class="col s6 m4 l3 blue-grey lighten-5"&gt;
        &lt;?php
              $data = ['value1' =&gt; $value['en'] ,'value2' =&gt; $value['jp'] ];
              $data_total = htmlspecialchars(json_encode($data));
         ?&gt;
          &lt;input type="checkbox" id="test5{{ $key }}" value="{{$data_total}}" name="test[]" /&gt;
          &lt;label for="test5{{ $key }}"&gt;{{$value['jp']}}&lt;/label&gt;
        &lt;/div&gt;
  @endforeach
  </code></pre>
  
  <p><strong>Laravel Controller</strong></p>
  
  <pre><code>return $request-&gt;test['0']['value1'];
  </code></pre>
  
  <p><strong>Error message</strong></p>
  
  <pre><code>Illegal string offset 'value1'
  </code></pre>