array_push strings which comes from json_encode for sql insertion
<p>Hello I would like to store string which comes from json encode to get it store in MySQL, but the thing is that the array returned nothing. Here is my code:</p>

<pre><code>    $com = array("1-1","1-2","1-3");
    $classcom=array();
    for ($i=1; $i&lt;(int)$totaleleve; $i++) {
      $eleve=array();
      foreach($com as $value)
       {
        array_push($eleve,'2');

       }
       $final="'".json_encode($eleve)."'";
       array_push($classcom,$final);
       echo $final;
       echo $classcom;
    }
    echo $classcom;
</code></pre>

<p>For your information, <code>$totaleleve='20'</code>, and  I do <code>$final="'".json_encode($eleve)."'";</code> so that I can concentrate strings of the array to be able to insert it into the SQL statement, which looks something like this:</p>

<pre><code>$sql="INSERT INTO table VALUES (".explode(",", $classcom).")"
// so that it looks like something like this:
$sql="INSERT INTO table VALUES ('["2","2","2"]','["2","2","2"]','["2","2","2"]')
</code></pre>

<p>the <code>$final</code> gave me <code>'["2","2","2"]'</code> which i wanted, but when i do <code>array_push($classcom,$final);</code>, it just gave me a blank array :</p>

<pre><code>Array
</code></pre>

<p>Can someone help me, please? Thank you!</p>