Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
Entrada enter = guardar datos en el archivo json

html:

 <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="style.css?v=2"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/> </head> <body> <div class="wrapper"> <div class="search-input"> <form method="post" action="store.php"> <input type="text" placeholder="Type to search.."> <input type="submit" value="Done"/> <div class="autocom-box"> <!-- here list are inserted from javascript --> </div> <div class="icon"><i class="fas fa-search"></i></div> </div> </div> <script src="suggestions.js?v=3"></script> <script src="js/script.js?v=2"></script> </body> </html>

sugerencia.js

 let suggestions = [ "YouTube", "YouTuber", "YouTube Channel", "Blogger", ];

Necesito eso cuando el usuario escribe algo en la entrada para que los datos se guarden y se escriban en json, pero no sé cómo no funcionó para mí a través de php, así que necesitaría ayuda para hacerlo en json.

tienda.php

 <?php $myfile = fopen("suggestions.js", "a+"); $txt = "Login name : ".$_POST['name'].; fwrite($myfile, $txt); fclose($myfile); ?>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

$jsonFile = '/path/to/your/json/suggestion.js'; $data = (file_exists($jsonFile)) ? json_decode(preg_replace('#^let suggestions = \[(.+)\];\s*$#', '$1', file_get_contents($jsonFile))) : []; $data[] = $_POST['name']; file_put_contents($jsonFile, 'let suggestions = ' . json_encode($data) . ';');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!