Foros del Web » Programando para Internet » PHP »

Modificar array

Estas en el tema de Modificar array en el foro de PHP en Foros del Web. Hola a [email protected], tengo el siguiente array(en realidad es un trozo de un array mucho mas grande): [rule] => Array ( [id] => chauffage_soir [condition] ...
  #1 (permalink)  
Antiguo 08/03/2008, 04:55
 
Fecha de Ingreso: abril-2005
Mensajes: 287
Antigüedad: 14 años, 10 meses
Puntos: 0
Modificar array

Hola a [email protected],

tengo el siguiente array(en realidad es un trozo de un array mucho mas grande):


[rule] => Array
(
[id] => chauffage_soir
[condition] => Array
(
[type] => and
[condition] => Array
(
[0] => Array //Subarray condition
(
[type] => object
[id] => absence
[value] => off
)

[1] => Array//Subarray condition
(
[type] => object
[id] => chauffage_auto
[value] => on
)

[2] => Array
(
[type] => timer
[trigger] => true
[at] => Array
(
[hour] => 21
[min] => 00
)

[until] => Array
(
[hour] => 23
[min] => 0
)

)

)

)

[actionlist] => Array
(
[0] => Array
(
[action] => Array
(
[0] => ArraySubarray action
(
[type] => set-value
[id] => chauffage_ch1
[value] => standby
)

[1] => Array
(
[type] => set-value
[id] => chauffage_ch2
[value] => standby
)

)

)

[1] => Array
(
[type] => on-false
[action] => Array
(
[0] => Array
(
[type] => set-value
[id] => chauffage_cuisine
[value] => night
)

[1] => Array
(
[type] => set-value
[id] => chauffage_salon
[value] => night
)

[2] => Array
(
[type] => set-value
[id] => chauffage_ch1
[value] => standby
)

[3] => Array
(
[type] => set-value
[id] => chauffage_ch2
[value] => night
)

[4] => Array
(
[type] => set-value
[id] => chauffage_bureau
[value] => night
)

[5] => Array
(
[type] => set-value
[id] => chauffage_sdb
[value] => off
)

)

)

)

)



Si os fijais,hay subarrays cuyo índice es un número(como por ejemplo los que he comentado en azul).Entonces lo que quiero es cambiar el indice numérico,por el nombre del índice del array padre(que puede ser action,condition,....) y además que el padre yo no aparezca.Es decir,quiero que se quede así:

[rule] => Array
(
[id] => chauffage_soir
[condition] => Array
(
[type] => and
[condition] => Array //Subarray condition
(
[type] => object
[id] => absence
[value] => off
)

[condition] => Array//Subarray condition
(
[type] => object
[id] => chauffage_auto
[value] => on
)

[condition] => Array
(
[type] => timer
[trigger] => true
[at] => Array
(
[hour] => 21
[min] => 00
)

[until] => Array
(
[hour] => 23
[min] => 0
)

)

[actionlist] => Array
(
[action] => ArraySubarray action
(
[type] => set-value
[id] => chauffage_ch1
[value] => standby
)

[action] => Array
(
[type] => set-value
[id] => chauffage_ch2
[value] => standby
)

)

[actionlist] => Array
(
[type] => on-false
[action] => Array
(
[type] => set-value
[id] => chauffage_cuisine
[value] => night
)

[action] => Array
(
[type] => set-value
[id] => chauffage_salon
[value] => night
)

[action] => Array
(
[type] => set-value
[id] => chauffage_ch1
[value] => standby
)

[action] => Array
(
[type] => set-value
[id] => chauffage_ch2
[value] => night
)

[action] => Array
(
[type] => set-value
[id] => chauffage_bureau
[value] => night
)

[action] => Array
(
[type] => set-value
[id] => chauffage_sdb
[value] => off
)

)

)




Gracias de antemano
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:32.