I need to modify a few things about a multidimensional array. First, I need to convert a key that contains an array into an element of that same array. In order to do that, I need to find the key's name. The problem here is that the key keeps changing it's name. The key I'm gonna base the modifications on is called "grupo*" and a number.
Here's an example of the array (extracted using the print_r() PHP function):
Array
(
[codigo] => 21201
[nombre] => CALCULO INTEGRAL
[creditos] => 3
[grupo8] => Array
(
[horario] => Array
(
[martes] => Array
(
[salon] => Array
(
[0] => G-216
[1] => G-216
)
[horaInicio] => Array
(
[0] => 1600
[1] => 1700
)
[horaFin] => Array
(
[0] => 1700
[1] => 1800
)
)
[jueves] => Array
(
[salon] => Array
(
[0] => C-102
[1] => C-102
)
[horaInicio] => Array
(
[0] => 1600
[1] => 1700
)
[horaFin] => Array
(
[0] => 1700
[1] => 1800
)
)
)
)
)
Array
(
[codigo] => 21202
[nombre] => FISICA MECANICA
[creditos] => 4
[grupo1] => Array
(
[horario] => Array
(
[lunes] => Array
(
[salon] => Array
(
[0] => Lab B-207
[1] => Lab B-207
)
[horaInicio] => Array
(
[0] => 1300
[1] => 1400
)
[horaFin] => Array
(
[0] => 1400
[1] => 1500
)
)
[martes] => Array
(
[salon] => Array
(
[0] => G-110
[1] => G-110
)
[horaInicio] => Array
(
[0] => 1300
[1] => 1400
)
[horaFin] => Array
(
[0] => 1400
[1] => 1500
)
)
[jueves] => Array
(
[salon] => Agora 101
[horaInicio] => 1300
[horaFin] => 1400
)
)
)
)
Array
(
[codigo] => 21203
[nombre] => ALGEBRA LINEAL
[creditos] => 3
[grupo13] => Array
(
[horario] => Array
(
[lunes] => Array
(
[salon] => B-108
[horaInicio] => 1100
[horaFin] => 1200
)
[viernes] => Array
(
[salon] => Array
(
[0] => B-107
[1] => B-107
)
[horaInicio] => Array
(
[0] => 1000
[1] => 1100
)
[horaFin] => Array
(
[0] => 1100
[1] => 1200
)
)
)
)
)
Array
(
[codigo] => 21304
[nombre] => PROGRAMACION ORIENTADA A OBJETOS
[creditos] => 3
[grupo4] => Array
(
[horario] => Array
(
[miercoles] => Array
(
[salon] => Array
(
[0] => B209 lab
[1] => B209 lab
[2] => B209 lab
)
[horaInicio] => Array
(
[0] => 1400
[1] => 1500
[2] => 1600
)
[horaFin] => Array
(
[0] => 1500
[1] => 1600
[2] => 1700
)
)
)
)
)
Array
(
[codigo] => 275201
[nombre] => MATEMATICAS DISCRETAS
[creditos] => 2
[grupo2] => Array
(
[horario] => Array
(
[jueves] => Array
(
[salon] => Array
(
[0] => A-203
[1] => A-203
)
[horaInicio] => Array
(
[0] => 1100
[1] => 1200
)
[horaFin] => Array
(
[0] => 1200
[1] => 1300
)
)
)
)
)
Array
(
[codigo] => MAKE
[nombre] => MARKETING ELECTRONICO
[creditos] => 2
[grupo1] => Array
(
[horario] => Array
(
[viernes] => Array
(
[salon] => Array
(
[0] => G-219
[1] => G-219
)
[horaInicio] => Array
(
[0] => 1200
[1] => 1300
)
[horaFin] => Array
(
[0] => 1300
[1] => 1400
)
)
)
)
)
As you can see, the key [grupo*] keeps changing number, and it can be a 1 or 2 digit number. The only thing I know is that such a key contains an array.
I need to do the same thing to one of the arrays inside, the one that is a weekday.
Here is an example of how the array is supposed to look (as JSON):
{
"codigo": "21201",
"nombre": "CALCULO INTEGRAL",
"creditos": "3",
"grupo": "8",
"horario": [
{
"dia": "martes",
"salon": [
"G-216",
"G-216"
],
"horaInicio": [
"1600",
"1700"
],
"horaFin": [
"1700",
"1800"
]
},
{
"dia": "jueves",
"salon": [
"C-102",
"C-102"
],
"horaInicio": [
"1600",
"1700"
],
"horaFin": [
"1700",
"1800"
]
}
]
}
The weekday keeps changing, so I have a similar problem there.