title: how to write a json file with php?
body: <p>I have 4 input, which sent by Ajax 4 data, to a php file:<br>
  how can I load json file and then add new data whih php?</p>
  
  <pre><code>&lt;input type="text" id="name"&gt;
  &lt;input type="text" id="surname"&gt;
  &lt;input type="text" id="mobile"&gt;
  &lt;input type="text" id="email"&gt;
  &lt;script&gt;
  var name = $("#name").val();
  var surname = $("#surname").val();
  var mobile = $("#mobile").val();
  var email = $("#email").val();
  $.ajax({type:"POST",
      url:"wjson.php",
      data:"name="+nombre+"&amp;surname="+surname+"&amp;mobile="+mobile+"&amp;email="+email,
      success:function(data) {
  
      }
  });
  </code></pre>
  
  <p></p>
  
  <p>JSON file: (people.json)</p>
  
  <pre><code>{
      "1":
      {
          "Name" : "Jhon",
          "Surname" : "Kenneth",
          "mobile" : 329129293,
          "email" : "jhon@gmail.com"
      },
      "2":
      {
          "Name" : "Thor",
          "Surname" : "zvalk",
          "mobile" : 349229293,
          "email" : "thor@gmail.com"
      }
  }
  </code></pre>
  
  <p>wjson.php file :</p>
  
  <pre><code>&lt;?php
  $nane = $_POST['name'];
  $surname =$_POST['surname'];
  $mobile = $_POST['mobile'];
  $email =$_POST['email'];
  $str_datos = file_get_contents("people.json")
  //add new data to people.json
  ?&gt;
  </code></pre>
  
  <p>by the way people.json file is in my server</p>