Simplify code using array I am trying to simplify the amount of code required here using arrays, I feel like my foreach loop is still excessively long. Any advice would be appreciated.

$date_list = Array(
Array( 'age', "$birthday", 'now' ),
Array( 'membership', "$datejoined", 'now' ),
Array( 'promoted', "$lastpromo", 'now' ),
);

foreach ( $date_list as $date_set ) {
$var = $date_set[0];
$start = $date_set[1];
$end  = $date_set[2];
$datetime1 = date_create($start);
$datetime2 = date_create($end);
$interval = date_diff($datetime1, $datetime2);
if ( substr_count( $var, 'age' ) &gt; 0 ){
    $age = $interval-&gt;format('%y');
}
elseif ( substr_count( $var, 'membership' ) &gt; 0 ){
    $years = $interval-&gt;format('%y');
    $months = $interval-&gt;format('%m');
    $membership = floor(($years*12)+$months);
    if($membership &gt; 1){
        $suffix = 'Months';
    }
    elseif($membership == 1){
        $suffix = 'Month';
    }
    else{
        $membership = "&lt; 1";
        $suffix = 'Month';
    }
}
elseif ( substr_count( $var, 'promoted' ) &gt; 0 ){
    $years = $interval-&gt;format('%y');
    $months = $interval-&gt;format('%m');
    $test = $interval-&gt;format('%a');
    $promoted = floor(($years*12)+$months);
    if($promoted &gt; 1){
        $suffix = 'Months ago';
    }
    elseif($promoted == 1){
        $suffix = 'Month ago';
    }
    else{
        $promoted = "&lt; 1";
        $suffix = 'ago';
    }
}


}
It's hard to suggest simplifications without a greater understanding of the problem being solved.  However, this is perhaps a bit more readable:

$dates = array(
    array('type' =&gt; 'age',        'start' =&gt; $birthday,   'stop' =&gt; 'now' ),
    array('type' =&gt; 'membership', 'start' =&gt; $datejoined, 'stop' =&gt; 'now' ),
    array('type' =&gt; 'promoted',   'start' =&gt; $lastpromo,  'stop' =&gt; 'now' ),
);

foreach($dates as $date)
{
    $start = date_create($date['start']);
    $stop  = date_create($date['stop']);
    $interval = date_diff($start, $stop);

    switch($date['type'])
    {
        case 'age':
            $age = $interval-&gt;format('%y');
            break;

        case 'membership':
            $years      = $interval-&gt;format('%y');
            $months     = $interval-&gt;format('%m');
            $membership = floor(($years*12)+$months);

            if($membership &gt;  1) { $suffix = 'Months'; }
            if($membership == 1) { $suffix = 'Month'; }
            if($membership &lt;  1) { $suffix = 'Month'; $membership = '&lt; 1'; }
            break;

        case 'prompted':
            $years    = $interval-&gt;format('%y');
            $months   = $interval-&gt;format('%m');
            $test     = $interval-&gt;format('%a');
            $promoted = floor(($years*12)+$months);

            if ($promoted  &gt; 1) { $suffix = 'Months ago'; }
            if ($promoted == 0) { $suffix = 'Month ago';  }
            if ($promoted  &lt; 1) { $suffix = 'ago'; $promoted = '&lt; 1'; }
            break;
    }
}


?