Hola estoy hace dos horas dandole vueltas a esta expresion regura para sacar lass variables de un string en un array:
La expresion:
?api_version=4&hotels=[{"ta_id":97497,"partner_id":"229547","partner_url" :"http://partner.com/deeplink/to/229547"},{"ta_id":97832,"partner_id":"id34234","pa rtner_url":"http://partner.com/deeplink/to/id34234"}]
&start_date=2013-07-01
&end_date=2013-07-03
&num_adults=2
&num_rooms=1
&lang=en_US
¤cy=USD
&user_country=US
&device_type=d
&query_key=6167a22d1f87d2028bf60a8e5e27afa7_191_13 60299600000_2_2
mi sentencia:
$keywords = preg_split("/[^a-zA-Z0-9_.\/]+/", $_POST[parametros]);
print_r($keywords);
Obtengo:
Array ( [0] => [1] => api_version [2] => 4 [3] => hotels [4] => ta_id [5] => 97497 [6] => partner_id [7] => 229547 [8] => partner_url [9] => http [10] => //partner.com/deeplink/to/229547 [11] => ta_id [12] => 97832 [13] => partner_id [14] => id34234 [15] => partner_url [16] => http [17] => //partner.com/deeplink/to/id34234 [18] => start_date [19] => 2013 [20] => 07 [21] => 01 [22] => end_date [23] => 2013 [24] => 07 [25] => 03 [26] => num_adults [27] => 2 [28] => num_rooms [29] => 1 [30] => lang [31] => en_US [32] => currency [33] => USD [34] => user_country [35] => US [36] => device_type [37] => d [38] => query_key [39] => 6167a22d1f87d2028bf60a8e5e27afa7_191_1360299600000 _2_2 )
Errores:
La posicion [0] siempre me aparece no se porque.
las posiones [9] y [10] me deberian aparecer enlazadas asi http://partner.com/deeplink/to/id34234
Llevo ya dos horas con esto y no consigo dar con la buena expresion....
por cierto la posicion [3] sobraria es decir "hotels" no aporta nada puedo prescindir de el aunque tampoco se como.
Gracias de anttemamo.