How to cast variable to array How to cast variable to array arrays arrays

How to cast variable to array


You can cast a variable to an array by using:

    $var = (array)$arr;


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);