Does anyone know of any problems, performance, or other features that might arise when moving a variable into an array, instead checking it first?
$v = array('1','2','3');
OR
$v = '1';
instead:
if (is_array($v)) foreach ($v as $value) {} else {}
I started using:
foreach((array) $v as $value) {
}
It stops code repetition quite a bit - but performance in my opinion, not ugly code.
Also, does anyone know how php processes an array array? There are no errors, but does the php server check the array array and then return the result before performing the casting process?
source
share