How to cast variable to array
arrays, casting, php, variables
Solution
You can cast a variable to an array by using:
$var = (array)$arr;
Problem
I have a variable $v that can be either single string or array of strings and I have a code: ``` $a = array(); if (is_array($v)) { $a = $v; } else { $a[] = $v; } ``` How it can be done in more elegant way? (in other words, how to cast a variable to array)