U
U
Uzumeti2018-12-22 19:01:32
1C-Bitrix
Uzumeti, 2018-12-22 19:01:32

Output of properties corresponding to a specific product?

Hello!
Please tell me the basics of programming in PHP. I'm trying to figure it out, but I don't have enough knowledge.
My task is this.
There is a product catalog in Bitrix, which contains product names, product properties and pictures. It is necessary to display on the page of the catalog with goods for each product the image corresponding to it . Wrote the simplest loop with foreach, which bypasses the array with information and selects elements (in this case, pictures) by key.
Then I try to display the image URLs for each product for the purpose of further substitution in the img src. As a result of such processing, I get for each product the number of pictures corresponding to the number of products in the section.
Those.all elements of the array are displayed in their entirety, by the key DETAIL_PICTURE . It turns out that the program bypasses the entire array and prints it all out.
Now the main question I don't understand. How is correspondence established in php that for a specific element it is necessary to display a specific element of the array, and not all elements of the array with the given key ? I watched how the standard catalog template was written. Thoughts did not appear. They do exactly the same, but there is only one picture, corresponding to a specific product.
It seems to me that this should be very easy to solve, but since it is not entirely clear what exactly to look for in the manual, problems arise.
Thanks to all.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yusif Zourab, 2018-12-22
@iLegion

Let's say we have some array $arrwith key . The output for this key displays all elements. To access the first element would be something like this['DETAIL_PICTURE']

$arr['DETAIL_PICTURE'][0], ко второму $arr['DETAIL_PICTURE'][1]
etc.
Read about associative arrays.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question