I start with a MySQL query (not of my design) that returns results that look like:
$row['user_name'];
$row['user_property']
$row['user_property_2']
$row['day_1']
$row['day_2']
$row['day_3']
$row['day_4']
$row['day_5']
What I would like to do is quickly (ideally in one step, not in a loop) replace (re-key) all of the field names that contain 'day_' to just have the number, resulting in:
$row['user_name'];
$row['user_property']
$row['user_property_2']
$row['1']
$row['2']
$row['3']
$row['4']
$row['5']
but without any risk to the other field name keys.
I imagine some solution that involves an "swap" array like:
$swap_array = ('day_1' => 1, 'day_2' => 2,'day_3' => 3, 'day_4' => 4, 'day_5' => 5);
But I'm not sure what function to implement the swap array. I am sure I've seen a native function for this before, but can't find it.