Answer the question
In order to leave comments, you need to log in
How to insert the result of an if?
I'm trying to make the correct yml file for Yandex. They had complaints about the availability of goods. Since the programmer is not currently on the project, you have to figure it out yourself.
There is such a design:
echo '<offers>';
foreach($items_res as $item){
echo '<offer id="'.$item['id'].'" available="<b>XXX</b>">';
Answer the question
In order to leave comments, you need to log in
echo '<offers>';
foreach($items_res as $item){
echo '<offer id="'.$item['id'].'" available="<b>' . if($item['num'] > 0) {echo 'true';} else {echo 'false';} . '</b>">';
Everything is simple, but you need to know the name of the field in the array that stores the count (if it is in your array at all, it is not clear from this piece of code). If you don't know, you can check like this:
foreach($items_res as $item){
echo '<pre>';
print_r($item);
echo '</pre>';
exit();
}
foreach($items_res as $item){
if ($item['kolichestvo']>0) echo '<offer id="'.$item['id'].'" available="true">';
else echo '<offer id="'.$item['id'].'" available="false">';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question