There is an HTML page from which fruit data is sent to the server using AJAX using the POST method.
On the PHP side, I accept this data:
$banana = $_POST['banana']; // 2 штуки $apple = $_POST['apple']; // 5 штук $orange = $_POST['orange']; // 3 штуки
Depending on the availability of variables, I have to output the text:
if (isset($banana)) { echo '2 банана'; } if (isset($banana) && isset($apple)) { echo '2 банана и 5 яблок'; } if (isset($banana) && isset($apple) && isset($orange)) { echo '2 банана, 5 яблок и 3 апельсина'; }
The problem is that the presence of all three variables in turn displays all 3 conditions, instead of the one you need:
'2 bananas2 bananas and 5 apples2 bananas, 5 apples and 3 oranges'.
It is clear why: all 3 variables exist.
I need that if all 3 variables are present at the same time, only one condition is output, and not three at once, that is, it should be:
echo '2 банана, 5 яблок и 3 апельсина';
If at the same time there are 2 variables, there is also one condition, without a superior, namely:
echo '2 банана и 5 яблок';
How can this be implemented?
Twig
, hmm, and the array can still be overGET
, transferred to different routes, we will pull up the router from theSymfony
package (and for every fireman’s package). - user207618