在PHP中使用foreach

I am trying to save data that is returned in array form to my table. However, I need to access the string in both GET inputs to do so. How can I achieve that? I can do it with one GET but not both.

    public function postDisableDates() {

    $input = Input::all();  

    foreach($input['date'] as $date) {

        $db_date = strtotime($date);

        $dateFormat = date('Y-m-d', strtotime("-1 month", $db_date));

    DB::table('bk_disable_date')
            ->delete();

    DB::table('bk_disable_date')
            ->insert(array(
                'date' => $dateFormat,
                'office' => $input['office']
            ));                     
    }       

}

var dump $input

array(3) { ["_token"]=> string(40) "Dr0pu8RUbTTe1t058Fb3sDjKQLLk1KMBnBrpV7m6" ["office"]=> array(4) { [0]=> string(3) "Office1" [1]=> string(10) "Office2" [2]=> string(10) "Office3" [3]=> string(10) "Office4" } ["date"]=> array(4) { [0]=> string(17) "25 December, 2013" [1]=> string(17) "14 December, 2013" [2]=> string(17) "05 December, 2013" [3]=> string(17) "23 November, 2013" } } 

var dump of $dateFormat in foreach loop

string(10) "2013-11-25" string(10) "2013-11-14" string(10) "2013-11-05" string(10) "2013-10-23" 

The $dateFormat part seems to be ok. I just need the office part to work the same way. Probably an easier way to achieve this.

my input names are set up as office[] and date[]. If that helps.

The disable date table is as follows

id  date    office
30  2013-11-25  Office1
31  2013-11-14  Office2
32  2013-11-05  Office3
33  2013-10-23  Office4

If the office and date keys are the same (which I assume), you could try that:

public function postDisableDates() {

  $input = Input::all();  

  DB::table('bk_disable_date')
    ->delete();

  foreach($input['date'] as $key => $date) {

    $db_date = strtotime($date);
    $dateFormat = date('Y-m-d', strtotime("-1 month", $db_date));

    DB::table('bk_disable_date')
      ->insert(array(
        'date' => $dateFormat,
        'office' => $input['office'][$key]
      )
    );                     
  }       
}

Hope that helps