I have a variable $v that can be either single string or array of stringsand I have a code:
$a = array(); if (is_array($v)) { $a = $v; } else { $
I would write your could snippet like this (short and you read it and know exactly what is happening):
$a = is_array($v) ? $v : array($v);
You can cast a variable to an array by using:
$var = (array)$arr;