I have a variable array that looks like this when var_dumped:
array (size=2)
0 =>
object(stdClass)[31]
public 'vacancy_calendar_id' => string '1' (length=1)
public 'vacancy_id' => string '1' (length=1)
public 'date_from' => string '2016-08-25 00:00:00' (length=19)
public 'date_to' => string '2016-08-27 00:00:00' (length=19)
1 =>
object(stdClass)[30]
public 'vacancy_calendar_id' => string '5' (length=1)
public 'vacancy_id' => string '1' (length=1)
public 'date_from' => string '2016-08-30 00:00:00' (length=19)
public 'date_to' => string '2016-08-30 00:00:00' (length=19)
Since I dont know how many of these elements will be in the array and I will merge it later with other arrays, I want it to look like this:
array (size=2)
0 =>
object(stdClass)[31]
public 'vacancy_calendar_id' => string '1' (length=1)
public 'vacancy_id' => string '1' (length=1)
public 'date_from_0' => string '2016-08-25 00:00:00' (length=19)
public 'date_to_0' => string '2016-08-27 00:00:00' (length=19)
public 'date_from_1' => string '2016-08-30 00:00:00' (length=19)
public 'date_to_1' => string '2016-08-30 00:00:00' (length=19)
And this should go on obviously for other elements, date_from_2, date_to_2, ...
vacancy_id. Whichvacancy_idshould be used in the combined object?