Source Code:
(back to article)
<?php $arr = [1, 1, 1, 1]; $first = $arr[0]; $same = true; for ($i = 1; $i < count($arr); $i++) { if ($arr[$i] !== $first) { $same = false; break; } } if ($same) { echo "All values are the same"; } else { echo "Values are not the same"; }
Result:
Report an issue