V
V
Vladislav2021-02-14 13:27:49
PHP
Vladislav, 2021-02-14 13:27:49

How to generate a list of products from JSON and display it on a page using PHP?

There is a JSON file from which you need to generate a list of products using PHP :

{
  "product": [
    {
      "name": "Капуста",
      "img": "http://pngimg.com/uploads/cabbage/cabbage_PNG8798.png",
      "price": "22"
    },
    {
     "name": "Капуста",
      "img": "http://pngimg.com/uploads/cabbage/cabbage_PNG8798.png",
      "price": "22"
    },
    {
      "name": "Капуста",
      "img": "http://pngimg.com/uploads/cabbage/cabbage_PNG8798.png",
      "price": "22"
    },
    {
      "name": "Капуста",
      "img": "http://pngimg.com/uploads/cabbage/cabbage_PNG8798.png",
      "price": "22"
    }
  ]
}


How can this be implemented?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
polak228, 2021-02-14
@Vl_T81

<?php
$file = json_decode(file_get_contents("file.json"));
echo $file -> product[0] -> name;

R
Rsa97, 2021-02-14
@Rsa97

A fantastic option is to learn PHP, HTML and CSS, write everything yourself.
A realistic option is to order freelance development.

S
Sergey Romanenko, 2021-02-14
@Awilum

here are all the answers https://www.php.net/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question