PHP Adding a Variable Into An Array

Adding a Variable Inside Array

With an array, you can use a variable to represent the value. The example below demonstrates a situation where a variable is used to display the days in the month.

$thirty_one = "Thirty one days in the month";
$thirty = "Thirty days in the month";
//$twenty_eight = "Twenty eight days in the month";

$values=array(
        "Jan" => $thirty_one,
        "Feb" => 28,
        "Mar" => $thirty_one,
        "Apr" => $thirty,
        "May" => $thirty_one,
        "Jun" => $thirty,
        "Jul" => $thirty_one,
        "Aug" => $thirty_one,
        "Sep" => $thirty,
        "Oct" => $thirty_one,
        "Nov" => $thirty,
        "Dec" => $thirty_one
    );