JSON in PHP (json_encode, json_decode)
Në shqip: JSON në PHP
ShpjegimiSQ
json_encode() e kthen një array ose objekt PHP në JSON, dhe json_decode($json, true) e kthen JSON-in në array. Kështu PHP-ja flet me JavaScript-in dhe me API të tjera.
EnglishEN
json_encode() turns a PHP array or object into JSON, and json_decode($json, true) turns JSON into an array. That's how PHP talks to JavaScript and other APIs.
Si ta mendosh
Si përkthyesi mes PHP-së dhe gjuhës që flasin të gjitha faqet.
Lexoje në anglisht
Like the translator between PHP and the language every website speaks.
Shembull kodiphp
<?php
header("Content-Type: application/json");
echo json_encode(["id" => "api", "emri" => "API"]);
$te_dhenat = json_decode($teksti, true);