<?php
$d = array();
echo intval($d) . "<br>";
$e = array("red", "green", "blue");
echo intval($e) . "<br>";
$values = array(-1,0,1,12,-100,1);
echo "output2" . (min(array_diff(array_map('intval', $values), array(0)))) . "<br>";
//echo min(array_diff(array_map('intval', $values), array(0))); also gives error
echo "output#2".min($values);
?>
The error message is:
2021/08/03 18:47:11 [error] 1888#1888: *3 FastCGI sent in stderr: “PHP message: PHP Parse error: syntax error, unexpected ‘$values’ (T_VARIABLE), expecting ‘,’ or ‘)’ in /var/www/html/w3_intvalf.php on line 7” while reading response header from upstream, client: 127.0.0.1, server: _, request: “GET /w3_intvalf.php HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.2-fpm.sock:”, host: “localhost”
Also I found that if I just do:
echo “output#2”.min($values);
my answer would be -100 which the syntax error prone code is trying to achieve:
echo “output2” . (min(array_diff(array_map(‘intval’, $values), array(0)))) . “
”;
I got the code from Q17 here:
Zulfi.