if ($result) {
if ($result == "right") {
$color = "green";
} else {
$color = "red";
}
$probablyColorize = " style='color:{$color}'";
} else {
$probablyColorize = null;
}
echo "<b{$probablyColorize}>";
$colorAttr = null;
if ($result == "right") {
$colorAttr = " style='color:green'";
} elseif ($result) {
$colorAttr = " style='color:red'";
}
echo "<b{$colorAttr}>";
Но удобство в том, что мы по сути один и тот же массив передаем в разные функции, и они берут то, что им надо
function crossConcat(array $someArray, array $otherArray) {
$concatenated = [];
foreach ($someArray as $someArrayElement) {
foreach ($otherArray as $otherArrayElement) {
$concatenated[] = $someArrayElement . $otherArrayElement;
}
}
return $concatenated;
}
$sites = ["site.com/file.php", "site2.net/file.php", "site3.irg/file.php"];
$paramStrings = ["?123", "?abc", "?777"];
var_dump(crossConcat($sites, $paramStrings));
/*
array(9) {
[0]=>
string(21) "site.com/file.php?123"
[1]=>
string(21) "site.com/file.php?abc"
[2]=>
string(21) "site.com/file.php?777"
[3]=>
string(22) "site2.net/file.php?123"
[4]=>
string(22) "site2.net/file.php?abc"
[5]=>
string(22) "site2.net/file.php?777"
[6]=>
string(22) "site3.irg/file.php?123"
[7]=>
string(22) "site3.irg/file.php?abc"
[8]=>
string(22) "site3.irg/file.php?777"
}
*/
$deviceCode = $_SESSION['isMobileOnly'] ? 3 : null;
$opinionList = $dao->getOpinionList($bar['id'], $deviceCode);
ORDER BY LEAST(
IF(SUBSTR(`date`, 1, 10)='', '9999-01-01', STR_TO_DATE(SUBSTR(`date`, 1, 10), '%d.%m.%Y')),
IF(SUBSTR(`date`, 12, 10)='', '9999-01-01', STR_TO_DATE(SUBSTR(`date`, 12, 10), '%d.%m.%Y')),
IF(SUBSTR(`date`, 23, 10)='', '9999-01-01', STR_TO_DATE(SUBSTR(`date`, 23, 10), '%d.%m.%Y'))
)
SELECT
MAX(ROUND((LENGTH(`date`) - LENGTH(REPLACE(`date`, '/', ''))) / LENGTH('/')))+1 AS 'max'
FROM
`dates`