iscode Posted January 8, 2014 Share Posted January 8, 2014 I have problem creating patern with preg_match_all and add it to array, its involved json data, Ch0cu3r helped me alot with my previous question http://forums.phpfreaks.com/topic/285059-preg-match-all-problem/, maybe he is still around? VI.data.aurora.idx = {140108: {act: 3, sun: ['s0','16:00','11:08','17:12','09:56'], moon: ['7','t3','03:51','']}, 140109: {act: 2, sun: ['s0','16:02','11:06','17:14','09:55'], moon: ['8','t3','05:12','']}, 140110: {act: 2, sun: ['s0','16:05','11:04','17:16','09:54'], moon: ['9','t3','06:28','']}, 140111: {act: 3, sun: ['s0','16:08','11:02','17:18','09:52'], moon: ['10','t3','07:35','']}, 140112: {act: 2, sun: ['s0','16:11','11:00','17:20','09:51'], moon: ['11','t3','08:30','']}, 140113: {act: 2, sun: ['s0','16:14','10:57','17:23','09:49'], moon: ['12','t3','09:11','']}, 140114: {act: 2, sun: ['s0','16:17','10:55','17:25','09:48'], moon: ['13','t3','09:41','']}, 140115: {act: 2, sun: ['s0','16:20','10:53','17:27','09:46'], moon: ['14','t4','16:33','10:03']}, 140116: {act: 2, sun: ['s0','16:23','10:50','17:30','09:44'], moon: ['15','t4','17:46','10:18']}, 140117: {act: 2, sun: ['s0','16:26','10:48','17:32','09:42'], moon: ['16','t4','19:03','10:30']}} Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/ Share on other sites More sharing options...
Ch0cu3r Posted January 8, 2014 Share Posted January 8, 2014 (edited) Try preg_match_all('#VI.data.aurora.idx = ({.*[^}]+}})#is', $data, $matches); /* This function was found at http://uk1.php.net/json_decode#95782 */ function json_decode_nice($json, $assoc = FALSE){ $json = str_replace(array("\n","\r"),"",$json); $json = str_replace("'", "\"", $json); // <--- I added $json = preg_replace('/([{,])(\s*)([^"]+?)\s*:/','$1"$3":',$json); return json_decode($json,$assoc); } // covert the javascript json into PHP json and return an associative array $auroraData = json_decode_nice($matches[1][0], true); printf('<pre>%s</pre>', print_r($auroraData, true)); Edited January 8, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464428 Share on other sites More sharing options...
iscode Posted January 8, 2014 Author Share Posted January 8, 2014 You really make it look so simple I really am trying to get my head into this but it will take me long time. Do you think the next one is possible? VI.imgConf[0] = {'title':'Total cloud cover','url':'total','0' : '/photos/ecm0125_island_tcc/140108_0000_3.png','tag0' : new Date(2014,1-1,8,3,0),'1' : '/photos/ecm0125_island_tcc/140108_0000_6.png','tag1' : new Date(2014,1-1,8,6,0),'2' : '/photos/ecm0125_island_tcc/140108_0000_9.png','tag2' : new Date(2014,1-1,8,9,0),'3' : '/photos/ecm0125_island_tcc/140108_0000_12.png','tag3' : new Date(2014,1-1,8,12,0),'4' : '/photos/ecm0125_island_tcc/140108_0000_15.png','tag4' : new Date(2014,1-1,8,15,0),'5' : '/photos/ecm0125_island_tcc/140108_0000_18.png','tag5' : new Date(2014,1-1,8,18,0),'6' : '/photos/ecm0125_island_tcc/140108_0000_21.png','tag6' : new Date(2014,1-1,8,21,0),'7' : '/photos/ecm0125_island_tcc/140108_0000_24.png','tag7' : new Date(2014,1-1,9,0,0),'8' : '/photos/ecm0125_island_tcc/140108_0000_27.png','tag8' : new Date(2014,1-1,9,3,0),'9' : '/photos/ecm0125_island_tcc/140108_0000_30.png','tag9' : new Date(2014,1-1,9,6,0),'10' : '/photos/ecm0125_island_tcc/140108_0000_33.png','tag10' : new Date(2014,1-1,9,9,0),'11' : '/photos/ecm0125_island_tcc/140108_0000_36.png','tag11' : new Date(2014,1-1,9,12,0),'12' : '/photos/ecm0125_island_tcc/140108_0000_39.png','tag12' : new Date(2014,1-1,9,15,0),'13' : '/photos/ecm0125_island_tcc/140108_0000_42.png','tag13' : new Date(2014,1-1,9,18,0),'14' : '/photos/ecm0125_island_tcc/140108_0000_45.png','tag14' : new Date(2014,1-1,9,21,0),'15' : '/photos/ecm0125_island_tcc/140108_0000_48.png','tag15' : new Date(2014,1-1,10,0,0),'16' : '/photos/ecm0125_island_tcc/140108_0000_51.png','tag16' : new Date(2014,1-1,10,3,0),'17' : '/photos/ecm0125_island_tcc/140108_0000_54.png','tag17' : new Date(2014,1-1,10,6,0),'18' : '/photos/ecm0125_island_tcc/140108_0000_57.png','tag18' : new Date(2014,1-1,10,9,0),'19' : '/photos/ecm0125_island_tcc/140108_0000_60.png','tag19' : new Date(2014,1-1,10,12,0),'20' : '/photos/ecm0125_island_tcc/140108_0000_66.png','tag20' : new Date(2014,1-1,10,18,0),'21' : '/photos/ecm0125_island_tcc/140108_0000_72.png','tag21' : new Date(2014,1-1,11,0,0),'22' : '/photos/ecm0125_island_tcc/140108_0000_78.png','tag22' : new Date(2014,1-1,11,6,0),'23' : '/photos/ecm0125_island_tcc/140108_0000_84.png','tag23' : new Date(2014,1-1,11,12,0),'24' : '/photos/ecm0125_island_tcc/140108_0000_90.png','tag24' : new Date(2014,1-1,11,18,0),'25' : '/photos/ecm0125_island_tcc/140108_0000_96.png','tag25' : new Date(2014,1-1,12,0,0),'26' : '/photos/ecm0125_island_tcc/140108_0000_102.png','tag26' : new Date(2014,1-1,12,6,0),'27' : '/photos/ecm0125_island_tcc/140108_0000_108.png','tag27' : new Date(2014,1-1,12,12,0),'28' : '/photos/ecm0125_island_tcc/140108_0000_114.png','tag28' : new Date(2014,1-1,12,18,0),'29' : '/photos/ecm0125_island_tcc/140108_0000_120.png','tag29' : new Date(2014,1-1,13,0,0),'30' : '/photos/ecm0125_island_tcc/140108_0000_126.png','tag30' : new Date(2014,1-1,13,6,0),'31' : '/photos/ecm0125_island_tcc/140108_0000_132.png','tag31' : new Date(2014,1-1,13,12,0),'32' : '/photos/ecm0125_island_tcc/140108_0000_138.png','tag32' : new Date(2014,1-1,13,18,0),'33' : '/photos/ecm0125_island_tcc/140108_0000_144.png','tag33' : new Date(2014,1-1,14,0,0),'34' : '/photos/ecm0125_island_tcc/140108_0000_150.png','tag34' : new Date(2014,1-1,14,6,0),'35' : '/photos/ecm0125_island_tcc/140108_0000_156.png','tag35' : new Date(2014,1-1,14,12,0),'36' : '/photos/ecm0125_island_tcc/140108_0000_162.png','tag36' : new Date(2014,1-1,14,18,0),'37' : '/photos/ecm0125_island_tcc/140108_0000_168.png','tag37' : new Date(2014,1-1,15,0,0),'38' : '/photos/ecm0125_island_tcc/140108_0000_174.png','tag38' : new Date(2014,1-1,15,6,0),'39' : '/photos/ecm0125_island_tcc/140108_0000_180.png','tag39' : new Date(2014,1-1,15,12,0),'40' : '/photos/ecm0125_island_tcc/140108_0000_186.png','tag40' : new Date(2014,1-1,15,18,0),'41' : '/photos/ecm0125_island_tcc/140108_0000_192.png','tag41' : new Date(2014,1-1,16,0,0),'42' : '/photos/ecm0125_island_tcc/140108_0000_198.png','tag42' : new Date(2014,1-1,16,6,0),'43' : '/photos/ecm0125_island_tcc/140108_0000_204.png','tag43' : new Date(2014,1-1,16,12,0),'44' : '/photos/ecm0125_island_tcc/140108_0000_210.png','tag44' : new Date(2014,1-1,16,18,0),'45' : '/photos/ecm0125_island_tcc/140108_0000_216.png','tag45' : new Date(2014,1-1,17,0,0),'46' : '/photos/ecm0125_island_tcc/140108_0000_222.png','tag46' : new Date(2014,1-1,17,6,0),'47' : '/photos/ecm0125_island_tcc/140108_0000_228.png','tag47' : new Date(2014,1-1,17,12,0),'48' : '/photos/ecm0125_island_tcc/140108_0000_234.png','tag48' : new Date(2014,1-1,17,18,0),'49' : '/photos/ecm0125_island_tcc/140108_0000_240.png','tag49' : new Date(2014,1-1,18,0,0),'mapCtrl':null };VI.imgConf[1] = {'title':'Lower clouds','url':'lower','0' : '/photos/ecm0125_island_lcc/140108_0000_3.png','tag0' : new Date(2014,1-1,8,3,0),'1' : '/photos/ecm0125_island_lcc/140108_0000_6.png','tag1' : new Date(2014,1-1,8,6,0),'2' : '/photos/ecm0125_island_lcc/140108_0000_9.png','tag2' : new Date(2014,1-1,8,9,0),'3' : '/photos/ecm0125_island_lcc/140108_0000_12.png','tag3' : new Date(2014,1-1,8,12,0),'4' : '/photos/ecm0125_island_lcc/140108_0000_15.png','tag4' : new Date(2014,1-1,8,15,0),'5' : '/photos/ecm0125_island_lcc/140108_0000_18.png','tag5' : new Date(2014,1-1,8,18,0),'6' : '/photos/ecm0125_island_lcc/140108_0000_21.png','tag6' : new Date(2014,1-1,8,21,0),'7' : '/photos/ecm0125_island_lcc/140108_0000_24.png','tag7' : new Date(2014,1-1,9,0,0),'8' : '/photos/ecm0125_island_lcc/140108_0000_27.png','tag8' : new Date(2014,1-1,9,3,0),'9' : '/photos/ecm0125_island_lcc/140108_0000_30.png','tag9' : new Date(2014,1-1,9,6,0),'10' : '/photos/ecm0125_island_lcc/140108_0000_33.png','tag10' : new Date(2014,1-1,9,9,0),'11' : '/photos/ecm0125_island_lcc/140108_0000_36.png','tag11' : new Date(2014,1-1,9,12,0),'12' : '/photos/ecm0125_island_lcc/140108_0000_39.png','tag12' : new Date(2014,1-1,9,15,0),'13' : '/photos/ecm0125_island_lcc/140108_0000_42.png','tag13' : new Date(2014,1-1,9,18,0),'14' : '/photos/ecm0125_island_lcc/140108_0000_45.png','tag14' : new Date(2014,1-1,9,21,0),'15' : '/photos/ecm0125_island_lcc/140108_0000_48.png','tag15' : new Date(2014,1-1,10,0,0),'16' : '/photos/ecm0125_island_lcc/140108_0000_51.png','tag16' : new Date(2014,1-1,10,3,0),'17' : '/photos/ecm0125_island_lcc/140108_0000_54.png','tag17' : new Date(2014,1-1,10,6,0),'18' : '/photos/ecm0125_island_lcc/140108_0000_57.png','tag18' : new Date(2014,1-1,10,9,0),'19' : '/photos/ecm0125_island_lcc/140108_0000_60.png','tag19' : new Date(2014,1-1,10,12,0),'20' : '/photos/ecm0125_island_lcc/140108_0000_66.png','tag20' : new Date(2014,1-1,10,18,0),'21' : '/photos/ecm0125_island_lcc/140108_0000_72.png','tag21' : new Date(2014,1-1,11,0,0),'22' : '/photos/ecm0125_island_lcc/140108_0000_78.png','tag22' : new Date(2014,1-1,11,6,0),'23' : '/photos/ecm0125_island_lcc/140108_0000_84.png','tag23' : new Date(2014,1-1,11,12,0),'24' : '/photos/ecm0125_island_lcc/140108_0000_90.png','tag24' : new Date(2014,1-1,11,18,0),'25' : '/photos/ecm0125_island_lcc/140108_0000_96.png','tag25' : new Date(2014,1-1,12,0,0),'26' : '/photos/ecm0125_island_lcc/140108_0000_102.png','tag26' : new Date(2014,1-1,12,6,0),'27' : '/photos/ecm0125_island_lcc/140108_0000_108.png','tag27' : new Date(2014,1-1,12,12,0),'28' : '/photos/ecm0125_island_lcc/140108_0000_114.png','tag28' : new Date(2014,1-1,12,18,0),'29' : '/photos/ecm0125_island_lcc/140108_0000_120.png','tag29' : new Date(2014,1-1,13,0,0),'30' : '/photos/ecm0125_island_lcc/140108_0000_126.png','tag30' : new Date(2014,1-1,13,6,0),'31' : '/photos/ecm0125_island_lcc/140108_0000_132.png','tag31' : new Date(2014,1-1,13,12,0),'32' : '/photos/ecm0125_island_lcc/140108_0000_138.png','tag32' : new Date(2014,1-1,13,18,0),'33' : '/photos/ecm0125_island_lcc/140108_0000_144.png','tag33' : new Date(2014,1-1,14,0,0),'34' : '/photos/ecm0125_island_lcc/140108_0000_150.png','tag34' : new Date(2014,1-1,14,6,0),'35' : '/photos/ecm0125_island_lcc/140108_0000_156.png','tag35' : new Date(2014,1-1,14,12,0),'36' : '/photos/ecm0125_island_lcc/140108_0000_162.png','tag36' : new Date(2014,1-1,14,18,0),'37' : '/photos/ecm0125_island_lcc/140108_0000_168.png','tag37' : new Date(2014,1-1,15,0,0),'38' : '/photos/ecm0125_island_lcc/140108_0000_174.png','tag38' : new Date(2014,1-1,15,6,0),'39' : '/photos/ecm0125_island_lcc/140108_0000_180.png','tag39' : new Date(2014,1-1,15,12,0),'40' : '/photos/ecm0125_island_lcc/140108_0000_186.png','tag40' : new Date(2014,1-1,15,18,0),'41' : '/photos/ecm0125_island_lcc/140108_0000_192.png','tag41' : new Date(2014,1-1,16,0,0),'42' : '/photos/ecm0125_island_lcc/140108_0000_198.png','tag42' : new Date(2014,1-1,16,6,0),'43' : '/photos/ecm0125_island_lcc/140108_0000_204.png','tag43' : new Date(2014,1-1,16,12,0),'44' : '/photos/ecm0125_island_lcc/140108_0000_210.png','tag44' : new Date(2014,1-1,16,18,0),'45' : '/photos/ecm0125_island_lcc/140108_0000_216.png','tag45' : new Date(2014,1-1,17,0,0),'46' : '/photos/ecm0125_island_lcc/140108_0000_222.png','tag46' : new Date(2014,1-1,17,6,0),'47' : '/photos/ecm0125_island_lcc/140108_0000_228.png','tag47' : new Date(2014,1-1,17,12,0),'48' : '/photos/ecm0125_island_lcc/140108_0000_234.png','tag48' : new Date(2014,1-1,17,18,0),'49' : '/photos/ecm0125_island_lcc/140108_0000_240.png','tag49' : new Date(2014,1-1,18,0,0),'mapCtrl':null };VI.imgConf[2] = {'title':'Middle clouds','url':'middle','0' : '/photos/ecm0125_island_mcc/140108_0000_3.png','tag0' : new Date(2014,1-1,8,3,0),'1' : '/photos/ecm0125_island_mcc/140108_0000_6.png','tag1' : new Date(2014,1-1,8,6,0),'2' : '/photos/ecm0125_island_mcc/140108_0000_9.png','tag2' : new Date(2014,1-1,8,9,0),'3' : '/photos/ecm0125_island_mcc/140108_0000_12.png','tag3' : new Date(2014,1-1,8,12,0),'4' : '/photos/ecm0125_island_mcc/140108_0000_15.png','tag4' : new Date(2014,1-1,8,15,0),'5' : '/photos/ecm0125_island_mcc/140108_0000_18.png','tag5' : new Date(2014,1-1,8,18,0),'6' : '/photos/ecm0125_island_mcc/140108_0000_21.png','tag6' : new Date(2014,1-1,8,21,0),'7' : '/photos/ecm0125_island_mcc/140108_0000_24.png','tag7' : new Date(2014,1-1,9,0,0),'8' : '/photos/ecm0125_island_mcc/140108_0000_27.png','tag8' : new Date(2014,1-1,9,3,0),'9' : '/photos/ecm0125_island_mcc/140108_0000_30.png','tag9' : new Date(2014,1-1,9,6,0),'10' : '/photos/ecm0125_island_mcc/140108_0000_33.png','tag10' : new Date(2014,1-1,9,9,0),'11' : '/photos/ecm0125_island_mcc/140108_0000_36.png','tag11' : new Date(2014,1-1,9,12,0),'12' : '/photos/ecm0125_island_mcc/140108_0000_39.png','tag12' : new Date(2014,1-1,9,15,0),'13' : '/photos/ecm0125_island_mcc/140108_0000_42.png','tag13' : new Date(2014,1-1,9,18,0),'14' : '/photos/ecm0125_island_mcc/140108_0000_45.png','tag14' : new Date(2014,1-1,9,21,0),'15' : '/photos/ecm0125_island_mcc/140108_0000_48.png','tag15' : new Date(2014,1-1,10,0,0),'16' : '/photos/ecm0125_island_mcc/140108_0000_51.png','tag16' : new Date(2014,1-1,10,3,0),'17' : '/photos/ecm0125_island_mcc/140108_0000_54.png','tag17' : new Date(2014,1-1,10,6,0),'18' : '/photos/ecm0125_island_mcc/140108_0000_57.png','tag18' : new Date(2014,1-1,10,9,0),'19' : '/photos/ecm0125_island_mcc/140108_0000_60.png','tag19' : new Date(2014,1-1,10,12,0),'20' : '/photos/ecm0125_island_mcc/140108_0000_66.png','tag20' : new Date(2014,1-1,10,18,0),'21' : '/photos/ecm0125_island_mcc/140108_0000_72.png','tag21' : new Date(2014,1-1,11,0,0),'22' : '/photos/ecm0125_island_mcc/140108_0000_78.png','tag22' : new Date(2014,1-1,11,6,0),'23' : '/photos/ecm0125_island_mcc/140108_0000_84.png','tag23' : new Date(2014,1-1,11,12,0),'24' : '/photos/ecm0125_island_mcc/140108_0000_90.png','tag24' : new Date(2014,1-1,11,18,0),'25' : '/photos/ecm0125_island_mcc/140108_0000_96.png','tag25' : new Date(2014,1-1,12,0,0),'26' : '/photos/ecm0125_island_mcc/140108_0000_102.png','tag26' : new Date(2014,1-1,12,6,0),'27' : '/photos/ecm0125_island_mcc/140108_0000_108.png','tag27' : new Date(2014,1-1,12,12,0),'28' : '/photos/ecm0125_island_mcc/140108_0000_114.png','tag28' : new Date(2014,1-1,12,18,0),'29' : '/photos/ecm0125_island_mcc/140108_0000_120.png','tag29' : new Date(2014,1-1,13,0,0),'30' : '/photos/ecm0125_island_mcc/140108_0000_126.png','tag30' : new Date(2014,1-1,13,6,0),'31' : '/photos/ecm0125_island_mcc/140108_0000_132.png','tag31' : new Date(2014,1-1,13,12,0),'32' : '/photos/ecm0125_island_mcc/140108_0000_138.png','tag32' : new Date(2014,1-1,13,18,0),'33' : '/photos/ecm0125_island_mcc/140108_0000_144.png','tag33' : new Date(2014,1-1,14,0,0),'34' : '/photos/ecm0125_island_mcc/140108_0000_150.png','tag34' : new Date(2014,1-1,14,6,0),'35' : '/photos/ecm0125_island_mcc/140108_0000_156.png','tag35' : new Date(2014,1-1,14,12,0),'36' : '/photos/ecm0125_island_mcc/140108_0000_162.png','tag36' : new Date(2014,1-1,14,18,0),'37' : '/photos/ecm0125_island_mcc/140108_0000_168.png','tag37' : new Date(2014,1-1,15,0,0),'38' : '/photos/ecm0125_island_mcc/140108_0000_174.png','tag38' : new Date(2014,1-1,15,6,0),'39' : '/photos/ecm0125_island_mcc/140108_0000_180.png','tag39' : new Date(2014,1-1,15,12,0),'40' : '/photos/ecm0125_island_mcc/140108_0000_186.png','tag40' : new Date(2014,1-1,15,18,0),'41' : '/photos/ecm0125_island_mcc/140108_0000_192.png','tag41' : new Date(2014,1-1,16,0,0),'42' : '/photos/ecm0125_island_mcc/140108_0000_198.png','tag42' : new Date(2014,1-1,16,6,0),'43' : '/photos/ecm0125_island_mcc/140108_0000_204.png','tag43' : new Date(2014,1-1,16,12,0),'44' : '/photos/ecm0125_island_mcc/140108_0000_210.png','tag44' : new Date(2014,1-1,16,18,0),'45' : '/photos/ecm0125_island_mcc/140108_0000_216.png','tag45' : new Date(2014,1-1,17,0,0),'46' : '/photos/ecm0125_island_mcc/140108_0000_222.png','tag46' : new Date(2014,1-1,17,6,0),'47' : '/photos/ecm0125_island_mcc/140108_0000_228.png','tag47' : new Date(2014,1-1,17,12,0),'48' : '/photos/ecm0125_island_mcc/140108_0000_234.png','tag48' : new Date(2014,1-1,17,18,0),'49' : '/photos/ecm0125_island_mcc/140108_0000_240.png','tag49' : new Date(2014,1-1,18,0,0),'mapCtrl':null };VI.imgConf[3] = {'title':'High clouds','url':'high','0' : '/photos/ecm0125_island_hcc/140108_0000_3.png','tag0' : new Date(2014,1-1,8,3,0),'1' : '/photos/ecm0125_island_hcc/140108_0000_6.png','tag1' : new Date(2014,1-1,8,6,0),'2' : '/photos/ecm0125_island_hcc/140108_0000_9.png','tag2' : new Date(2014,1-1,8,9,0),'3' : '/photos/ecm0125_island_hcc/140108_0000_12.png','tag3' : new Date(2014,1-1,8,12,0),'4' : '/photos/ecm0125_island_hcc/140108_0000_15.png','tag4' : new Date(2014,1-1,8,15,0),'5' : '/photos/ecm0125_island_hcc/140108_0000_18.png','tag5' : new Date(2014,1-1,8,18,0),'6' : '/photos/ecm0125_island_hcc/140108_0000_21.png','tag6' : new Date(2014,1-1,8,21,0),'7' : '/photos/ecm0125_island_hcc/140108_0000_24.png','tag7' : new Date(2014,1-1,9,0,0),'8' : '/photos/ecm0125_island_hcc/140108_0000_27.png','tag8' : new Date(2014,1-1,9,3,0),'9' : '/photos/ecm0125_island_hcc/140108_0000_30.png','tag9' : new Date(2014,1-1,9,6,0),'10' : '/photos/ecm0125_island_hcc/140108_0000_33.png','tag10' : new Date(2014,1-1,9,9,0),'11' : '/photos/ecm0125_island_hcc/140108_0000_36.png','tag11' : new Date(2014,1-1,9,12,0),'12' : '/photos/ecm0125_island_hcc/140108_0000_39.png','tag12' : new Date(2014,1-1,9,15,0),'13' : '/photos/ecm0125_island_hcc/140108_0000_42.png','tag13' : new Date(2014,1-1,9,18,0),'14' : '/photos/ecm0125_island_hcc/140108_0000_45.png','tag14' : new Date(2014,1-1,9,21,0),'15' : '/photos/ecm0125_island_hcc/140108_0000_48.png','tag15' : new Date(2014,1-1,10,0,0),'16' : '/photos/ecm0125_island_hcc/140108_0000_51.png','tag16' : new Date(2014,1-1,10,3,0),'17' : '/photos/ecm0125_island_hcc/140108_0000_54.png','tag17' : new Date(2014,1-1,10,6,0),'18' : '/photos/ecm0125_island_hcc/140108_0000_57.png','tag18' : new Date(2014,1-1,10,9,0),'19' : '/photos/ecm0125_island_hcc/140108_0000_60.png','tag19' : new Date(2014,1-1,10,12,0),'20' : '/photos/ecm0125_island_hcc/140108_0000_66.png','tag20' : new Date(2014,1-1,10,18,0),'21' : '/photos/ecm0125_island_hcc/140108_0000_72.png','tag21' : new Date(2014,1-1,11,0,0),'22' : '/photos/ecm0125_island_hcc/140108_0000_78.png','tag22' : new Date(2014,1-1,11,6,0),'23' : '/photos/ecm0125_island_hcc/140108_0000_84.png','tag23' : new Date(2014,1-1,11,12,0),'24' : '/photos/ecm0125_island_hcc/140108_0000_90.png','tag24' : new Date(2014,1-1,11,18,0),'25' : '/photos/ecm0125_island_hcc/140108_0000_96.png','tag25' : new Date(2014,1-1,12,0,0),'26' : '/photos/ecm0125_island_hcc/140108_0000_102.png','tag26' : new Date(2014,1-1,12,6,0),'27' : '/photos/ecm0125_island_hcc/140108_0000_108.png','tag27' : new Date(2014,1-1,12,12,0),'28' : '/photos/ecm0125_island_hcc/140108_0000_114.png','tag28' : new Date(2014,1-1,12,18,0),'29' : '/photos/ecm0125_island_hcc/140108_0000_120.png','tag29' : new Date(2014,1-1,13,0,0),'30' : '/photos/ecm0125_island_hcc/140108_0000_126.png','tag30' : new Date(2014,1-1,13,6,0),'31' : '/photos/ecm0125_island_hcc/140108_0000_132.png','tag31' : new Date(2014,1-1,13,12,0),'32' : '/photos/ecm0125_island_hcc/140108_0000_138.png','tag32' : new Date(2014,1-1,13,18,0),'33' : '/photos/ecm0125_island_hcc/140108_0000_144.png','tag33' : new Date(2014,1-1,14,0,0),'34' : '/photos/ecm0125_island_hcc/140108_0000_150.png','tag34' : new Date(2014,1-1,14,6,0),'35' : '/photos/ecm0125_island_hcc/140108_0000_156.png','tag35' : new Date(2014,1-1,14,12,0),'36' : '/photos/ecm0125_island_hcc/140108_0000_162.png','tag36' : new Date(2014,1-1,14,18,0),'37' : '/photos/ecm0125_island_hcc/140108_0000_168.png','tag37' : new Date(2014,1-1,15,0,0),'38' : '/photos/ecm0125_island_hcc/140108_0000_174.png','tag38' : new Date(2014,1-1,15,6,0),'39' : '/photos/ecm0125_island_hcc/140108_0000_180.png','tag39' : new Date(2014,1-1,15,12,0),'40' : '/photos/ecm0125_island_hcc/140108_0000_186.png','tag40' : new Date(2014,1-1,15,18,0),'41' : '/photos/ecm0125_island_hcc/140108_0000_192.png','tag41' : new Date(2014,1-1,16,0,0),'42' : '/photos/ecm0125_island_hcc/140108_0000_198.png','tag42' : new Date(2014,1-1,16,6,0),'43' : '/photos/ecm0125_island_hcc/140108_0000_204.png','tag43' : new Date(2014,1-1,16,12,0),'44' : '/photos/ecm0125_island_hcc/140108_0000_210.png','tag44' : new Date(2014,1-1,16,18,0),'45' : '/photos/ecm0125_island_hcc/140108_0000_216.png','tag45' : new Date(2014,1-1,17,0,0),'46' : '/photos/ecm0125_island_hcc/140108_0000_222.png','tag46' : new Date(2014,1-1,17,6,0),'47' : '/photos/ecm0125_island_hcc/140108_0000_228.png','tag47' : new Date(2014,1-1,17,12,0),'48' : '/photos/ecm0125_island_hcc/140108_0000_234.png','tag48' : new Date(2014,1-1,17,18,0),'49' : '/photos/ecm0125_island_hcc/140108_0000_240.png','tag49' : new Date(2014,1-1,18,0,0),'mapCtrl':null };VI.imgConf[4] = {'title':'Composite','url':'composite','0' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_3.png','tag0' : new Date(2014,1-1,8,3,0),'1' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_6.png','tag1' : new Date(2014,1-1,8,6,0),'2' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_9.png','tag2' : new Date(2014,1-1,8,9,0),'3' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_12.png','tag3' : new Date(2014,1-1,8,12,0),'4' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_15.png','tag4' : new Date(2014,1-1,8,15,0),'5' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_18.png','tag5' : new Date(2014,1-1,8,18,0),'6' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_21.png','tag6' : new Date(2014,1-1,8,21,0),'7' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_24.png','tag7' : new Date(2014,1-1,9,0,0),'8' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_27.png','tag8' : new Date(2014,1-1,9,3,0),'9' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_30.png','tag9' : new Date(2014,1-1,9,6,0),'10' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_33.png','tag10' : new Date(2014,1-1,9,9,0),'11' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_36.png','tag11' : new Date(2014,1-1,9,12,0),'12' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_39.png','tag12' : new Date(2014,1-1,9,15,0),'13' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_42.png','tag13' : new Date(2014,1-1,9,18,0),'14' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_45.png','tag14' : new Date(2014,1-1,9,21,0),'15' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_48.png','tag15' : new Date(2014,1-1,10,0,0),'16' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_51.png','tag16' : new Date(2014,1-1,10,3,0),'17' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_54.png','tag17' : new Date(2014,1-1,10,6,0),'18' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_57.png','tag18' : new Date(2014,1-1,10,9,0),'19' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_60.png','tag19' : new Date(2014,1-1,10,12,0),'20' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_66.png','tag20' : new Date(2014,1-1,10,18,0),'21' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_72.png','tag21' : new Date(2014,1-1,11,0,0),'22' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_78.png','tag22' : new Date(2014,1-1,11,6,0),'23' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_84.png','tag23' : new Date(2014,1-1,11,12,0),'24' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_90.png','tag24' : new Date(2014,1-1,11,18,0),'25' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_96.png','tag25' : new Date(2014,1-1,12,0,0),'26' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_102.png','tag26' : new Date(2014,1-1,12,6,0),'27' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_108.png','tag27' : new Date(2014,1-1,12,12,0),'28' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_114.png','tag28' : new Date(2014,1-1,12,18,0),'29' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_120.png','tag29' : new Date(2014,1-1,13,0,0),'30' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_126.png','tag30' : new Date(2014,1-1,13,6,0),'31' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_132.png','tag31' : new Date(2014,1-1,13,12,0),'32' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_138.png','tag32' : new Date(2014,1-1,13,18,0),'33' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_144.png','tag33' : new Date(2014,1-1,14,0,0),'34' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_150.png','tag34' : new Date(2014,1-1,14,6,0),'35' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_156.png','tag35' : new Date(2014,1-1,14,12,0),'36' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_162.png','tag36' : new Date(2014,1-1,14,18,0),'37' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_168.png','tag37' : new Date(2014,1-1,15,0,0),'38' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_174.png','tag38' : new Date(2014,1-1,15,6,0),'39' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_180.png','tag39' : new Date(2014,1-1,15,12,0),'40' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_186.png','tag40' : new Date(2014,1-1,15,18,0),'41' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_192.png','tag41' : new Date(2014,1-1,16,0,0),'42' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_198.png','tag42' : new Date(2014,1-1,16,6,0),'43' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_204.png','tag43' : new Date(2014,1-1,16,12,0),'44' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_210.png','tag44' : new Date(2014,1-1,16,18,0),'45' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_216.png','tag45' : new Date(2014,1-1,17,0,0),'46' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_222.png','tag46' : new Date(2014,1-1,17,6,0),'47' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_228.png','tag47' : new Date(2014,1-1,17,12,0),'48' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_234.png','tag48' : new Date(2014,1-1,17,18,0),'49' : '/photos/ecm0125_island_tcc_lcc_mcc_hcc/140108_0000_240.png','tag49' : new Date(2014,1-1,18,0,0),'mapCtrl':null }; Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464434 Share on other sites More sharing options...
Ch0cu3r Posted January 8, 2014 Share Posted January 8, 2014 (edited) lol, How much data are you ripping? The code here is almost the same as the quakeInfo code, the only thing that has changed is the regex. I am also using the json_decode_nice function I posted earlier to decode the json easier. preg_match_all('~VI.imgConf\[\d+\] = ({[^}]+});~', $data, $matches); $imgConf = array(); foreach ($matches[1] as $conf) { // convert the date into a timestamp $conf = preg_replace_callback('~new Date\(([^)]+)\)~', function($dateParams) { // get the date parameters list($year, $month, $day, $hour, $min) = explode(',', $dateParams[1]); // remove the javascript math operation for the month $month = substr($month, 0, strpos($month, '-')); // create the timestamp return mktime($hour, $min, 0, $month, $day, $year); }, $conf); // covert the javascript json into PHP json and return an associative array $imgConf[] = json_decode_nice($conf, true); } printf('<pre>%s</pre>', print_r($imgConf, true)); Edited January 8, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464445 Share on other sites More sharing options...
iscode Posted January 8, 2014 Author Share Posted January 8, 2014 lol I think I have almost enough for few days now maybe one last question for now and hopefully if I have more problems I can bother you more VI.data.aurora.text = { txt: 'Cloudy in the north. Fair in the south but gradually becoming overcast, mainly at the south coast. Likely the best places to see the sky in the southwest is the upcountry in west and then the upcountry in the south.', night: new Date(2014,1-1,8,0,0), valid_from: new Date(2014,1-1,8,20,0), valid_until: new Date(2014,1-1,9,4,0) }; btw, thank you for the link to the json_decode_nice function Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464454 Share on other sites More sharing options...
Ch0cu3r Posted January 8, 2014 Share Posted January 8, 2014 (edited) Use the same code from my last post but change imgConf\[\d+\] to data.aurora.text in the regex Edited January 8, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464461 Share on other sites More sharing options...
Ch0cu3r Posted January 8, 2014 Share Posted January 8, 2014 (edited) Been playing and have come up with a function that will scrape all VI.* variables from the page and convert them into associative array function json_decode_nice($json, $assoc = FALSE) { $json = str_replace(array("\n","\r"),"",$json); $json = str_replace("'", "\"", $json); // convert the date into a timestamp $json = preg_replace_callback('~new Date\(([^)]+)\)~', function($dateParams) { // get the date parameters $tmp = explode(',', $dateParams[1]); if(count($tmp) < 6) $tmp[5] = 0; list($year, $month, $sec, $day, $hour, $min) = $tmp; // remove the javascript math operation for the month $month = substr($month, 0, strpos($month, '-')); // create the timestamp return mktime($hour, $min, $sec, $month, $day, $year); }, $json); $json = preg_replace('/([{,])(\s*)([^"]+?)\s*:/','$1"$3":',$json); return json_decode($json,$assoc); } function find_VI_json($data) { $VI_data = array(); // find all VI.* variables that have JSON preg_match_all("~VI.([^\s]+) = (\[?{[^;]+}\]?)~is", $data, $matches); foreach ($matches[2] as $key => $json) { // decode JSON to array $jsonArray = json_decode_nice($json, true); // if an array was returned then JSON was decoded. if(is_array($jsonArray)) { // get the javascript variable name which this JSON belongs to $jsVar = $matches[1][$key]; // is this variable an array? if(strpos($jsVar, '[') !== false) { // get the array name $jsVar = substr($jsVar, 0, strpos($jsVar, '[')); // append jsonArray to variable array $VI_data[$jsVar][] = $jsonArray; } else $VI_data[$jsVar] = $jsonArray; } } return $VI_data; } To convert all JSON variables to an array just call $VI = find_VI_json($data); When you want to get a javascript variable you'd use its name, eg $VI['data.aurora.idx] to get the VI.data.aurora.idx json array Edited January 8, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464467 Share on other sites More sharing options...
iscode Posted January 8, 2014 Author Share Posted January 8, 2014 Really awesome work you done here but it wont take the data.aurora.idx into the array but everything else even on the quakeInfo page. I think I do the setup correct though: $data = file_get_contents('... $VI = find_VI_json($data); printf('<pre>%s</pre>', print_r($VI, true));printf('<pre>%s</pre>', print_r($VI['data.aurora.idx'], true)); Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464497 Share on other sites More sharing options...
Ch0cu3r Posted January 9, 2014 Share Posted January 9, 2014 (edited) The json definition for data.aurora.idx doesn't end in a semi-colon. This causes the regex to capture the if statement that follows it, which then causes json_decode to fail and so the data for it is not returned. As a hack, change function find_VI_json($data) { $VI_data = array(); to function find_VI_json($data) { $VI_data = array(); // HACK Fix - add semi-colon after two curly braces $data = preg_replace('~(}})\s*~', "$1;\n", $data); Edited January 9, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464506 Share on other sites More sharing options...
iscode Posted January 9, 2014 Author Share Posted January 9, 2014 (edited) I have 4 more VI.data that your last function work on but only if I remove the spaces before and after = // find all VI.* variables that have JSON preg_match_all("~VI.([^\s]+) = (\[?{[^;]+}\]?)~is", $data, $matches); <-- Before preg_match_all("~VI.([^\s]+)=(\[?{[^;]+}\]?)~is", $data, $matches); <-- After Is it possible somehow to remove those spaces if needed in the patern? Then I have 1 more VI.data that does not work even though I remove the spaces before and after = VI.data={"data1":"text1","data2":"text2","data3":"text3",data4:{text4a:1,text4b:1},"data5":"text5","data6":"text6","data7":"text7",data8:"text8"}}; Edited January 9, 2014 by iscode Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464647 Share on other sites More sharing options...
Ch0cu3r Posted January 10, 2014 Share Posted January 10, 2014 Change preg_match_all to preg_match_all("~VI.([^\s]+)\s*=\s*(\[?{[^;]+}\]?)~is", $data, $matches); Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464690 Share on other sites More sharing options...
iscode Posted January 10, 2014 Author Share Posted January 10, 2014 Thank you it worked for the first 4 data but not the last one Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464697 Share on other sites More sharing options...
Ch0cu3r Posted January 10, 2014 Share Posted January 10, 2014 (edited) Ok, change the regex match to preg_match_all("~VI.([^=]+)=\s*(\[?{[^;]+}\]?)~is", $data, $matches); And change $jsVar = $matches[1][$key]; to $jsVar = trim($matches[1][$key]); Edited January 10, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464703 Share on other sites More sharing options...
iscode Posted January 10, 2014 Author Share Posted January 10, 2014 No it wont wok on: VI.data={"data1":"text1","data2":"text2","data3":"text3",data4:{text4a:1,text4b:1},"data5":"text5","data6":"text6","data7":"text7",data8:"text8"}}; Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464706 Share on other sites More sharing options...
Ch0cu3r Posted January 10, 2014 Share Posted January 10, 2014 (edited) Where are you getting that from? As it is not valid JSON syntax, my regex will match it however json_decode will not decode it, due to having too many (closing) } braces. VI.data={"data1":"text1","data2":"text2","data3":"text3",data4:{text4a:1,text4b:1},"data5":"text5","data6":"text6","data7":"text7",data8:"text8"}}; // ^ too many braces here, making it invalid JSON Edited January 10, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464715 Share on other sites More sharing options...
iscode Posted January 10, 2014 Author Share Posted January 10, 2014 (edited) Ohh it must be my fault because I did a count for each { and } should be 13 each, I did try the function on the actual data but failed, here is the actual VI.data: VI.r={"company":" Icelandic Meteorological Office","frontpage":"Front page","yes":"Yes","no":"No","view":"View","hide":"Hide","reset":"Reset","close":"Close","made":"made","number":"Number","to":"to","more":"More","back":"Back","back_s_map":"Back to small map","view_onmap":"View on map",ucase:{day:1,mon:1},"mon_long1":"January","mon_long2":"February","mon_long3":"March","mon_long4":"April","mon_long5":"May","mon_long6":"Jume","mon_long7":"July","mon_long8":"August","mon_long9":"September","mon_long10":"October","mon_long11":"November","mon_long12":"December","mon_short1":"Jan","mon_short2":"Feb","mon_short3":"Mar","mon_short4":"Apr","mon_short5":"May","mon_short6":"Jun","mon_short7":"Jul","mon_short8":"Aug","mon_short9":"Sep","mon_short10":"Oct","mon_short11":"Nov","mon_short12":"Dec","day_long0":"Sunday","day_long1":"Monday","day_long2":"Tuesday","day_long3":"Wednesday","day_long4":"Thursday","day_long5":"Friday","day_long6":"Saturday","day_short0":"Sun","day_short1":"Mon","day_short2":"Tue","day_short3":"Wed","day_short4":"Thu","day_short5":"Fri","day_short6":"Sat","evening0":"Sunday evening","evening1":"Monday evening","evening2":"Tuesday evening","evening3":"Wednesday evening","evening4":"Thursday evening","evening5":"Friday evening","evening6":"Saturday evening","wtype1":"Clear sky","wtype2":"Partly cloudy","wtype3":"Cloudy","wtype4":"Overcast","wtype5":"Light rain","wtype6":"Rain","wtype7":"Light sleet","wtype8":"Sleet","wtype9":"Light snow","wtype10":"Snow","wtype11":"Rain showers","wtype12":"Sleet shower","wtype13":"Hail","wtype14":"Dust devil","wtype15":"Dust storm","wtype16":"Blowing snow","wtype17":"Fog","wtype18":"Light drizzle","wtype19":"Drizzle","wtype20":"Freezing rain","wtype21":"Hail","wtype22":"Light thunder","wtype23":"Thunder","wtype?":"No information","windv":"Variable wind dir.","windc":"Calm","windn":"Northerly","windnne":"North-north-easterly","windne":"North-easterly","windene":"East-north-easterly","winde":"Easterly","windese":"East-south-easterly","windse":"South-easterly","windsse":"South-south-easterly","winds":"Southerly","windssw":"South-south-westerly","windsw":"South-westerly","windwsw":"West-south-westerly","windw":"Westerly","windwnw":"West-north-westerly","windnw":"North-westerly","windnnw":"North-north-westerly","wind?":"No information","windshv":"Var","windshc":"Ca","windshn":"N","windshnne":"NNE","windshne":"NE","windshene":"ENE","windshe":"E","windshese":"ESE","windshse":"SE","windshsse":"SSE","windshs":"S","windshssw":"SSW","windshsw":"SW","windshwsw":"WSW","windshw":"W","windshwnw":"WNW","windshnw":"NW","windshnnw":"NNW","windsh?":"?","SNC0":"mostly ice-covered","SNC1":"partly snow-covered","SNC2":"mostly snow-covered","SNC3":"total but even snow-cover","SNC4":"total but uneven snow-cover","SNC5":"partly covered by loose snow","SNC6":"mostly covered by loose snow","SNC7":"loose snow covering the ground completely","SNC8":"total but uneven cover of loose snow","SNC9":"totally covered by snow and snow drifts","SED0":"calm","SED1":"rippled","SED2":"smooth","SED3":"slight","SED4":"moderate","SED5":"rough","SED6":"very rough","SED7":"high","SED8":"very high","SED9":"phenomenal","SED10":"information unavailable","N0":"Clear sky","N1":"Sunny (1/8)","N2":"Sunny (2/8)","N3":"Sunny (3/8)","N4":"Partly cloudy","N5":"Cloudy (5/8)","N6":"Cloudy (6/8)","N7":"Cloudy (7/8)","N8":"Overcast","N9":"Obscured",click_view:"Click to view larger ",elmaptype:{w:"wind forecast map",t:"temperature forecast map",p:"precipitation forecast map",m:"all element forecast map"},"type_sh":"type","hour_sh":"h","time_sh":"GMT","today":"Today","observs":"Weather observations","observ":"Observations","obs":"Obs.","obs_done":"Observation done","forec_done":"Forecast done","valid_from":"Valid from","valid_till":"Valid untill","forecast":"Forecast","forec":"Forec.","auto_forecast":"Automatic forecast","meteo":"Meteogram","meteo_hide":"Hide meteo.","meteo_view":"Show meteo.","windforec":"Wind","tempforec":"Temperature","precforec":"Precipitation","stforec":"Station forecasts","getting_s_obs":"Retrieving previous observations","enter_station":"Enter weather station name","sel_region":"Select region","forecnext24h":"Forecast for next 24 hours","forecnextfewdays":"Forecast for next few days","forecasttime":"Time-span","getgraphs":"Retrieving graph...","getphoto":"Retrieving image...","getwdata":"Retrieving weather data...","getphoto_first":"Retrieving first image...","getphoto_other":"Retrieving the image...","getphoto_error":"The Web-server did not receive the image","getphoto_abort":"Processing was cancelled; press F5 to re-process the image","getphoto_smallprint":"If the image does not appear soon, then an error has occurred during the processing of the image","info_unavail":"Information not found","prelim_results":"Preliminary results","didnt_find_wstation":"Weather station not found","noforec_viewobs":"Forecasts are not produced for this station; do you wish to view observational data instead?","noobs_viewforec":"Observations are unavailable for this station; do you wish to view the forecast for this station?","stforec_not_avail_4ftime":"Station forecast not available for this forecast hour","stationlist":"Weather stations","enterletter":"Click on a letter to find a name beginning with that letter","ttit_time":"Time","ttit_weather":"Weather","ttit_wind":"Wind","ttit_temp":"Temp.","ttit_precip_coll":"Cumul. precipi-<br/>tation","ttit_cloudcover":"Cloud cover","ttit_dewpoint":"Dew point","ttit_maxwind":"Max. wind speed","ttit_roadtemp":"Road temp.","ttit_humidity":"Humid-<br/>ity","ttit_visib":"Visibility","ttit_snowdepth":"Snow depth","ttit_snow":"Snow","ttit_sea":"Snow cover","ttit_pressure":"Atmos-<br/>pheric pressure","tit_temp":"Temperature","tit_wind":"Wind","tit_storm":"Storm","tit_maxgust":"Maximum gust","tit_frost":"Frost","tit_snowdepth":"Snow depth","tit_visib":"Visibility","tit_max10wind":"Maximum 10-minute wind","tit_roadtemp":"Road temperature","tit_humidity":"Humidity","tit_pressure":"Atmospheric pressure","tit_sea":"Sea condition","tit_windstren":"Wind strength","tit_winddir":"Wind direction","tit_tempdewp":"Temperature and dew-point","tit_precip":"Precipitation","tit_sunradi":"Solar radiation","tit_soaltemp":"Soil temperature","tit_radioact":"Rad. activity strength","tit_wattemp":"Water temperature","tit_watlevel":"Water level","creating_tabl":"Creating table - one moment","directly_to":"directly to","dirto_stlist":"Directly to station list","backto_stlist":"Return to station list","wdata_nowind":"Information about wind is not available","prec_last":"Precipitation last","prec_next":"Precipitation next","noremark":"No remarks","txtfcst_unavail":"Text forecast for this region is not available in English",warea:{101:"Whole country",111:"Reykjavik area",1:"Faxaflói",2:"Breiðafjörður",3:"West fjords",4:"North West",5:"North East",6:"Eastern coastal areas",7:"East fjords",8:"South East",9:"South",10:"Central highlands",1301:"Djúpið"},latlon:{lat:65,lon:-19,gm_zoom:5},"wmap":{"info_selstationgroup":"Select the group of stations from the list","wdata_getting":"Retrieving weather data","wdata_errget":"Unable to display the weather data due to an error","g_Yfirlitsstöðvar":"Overview stations","g_Strandstöðvar":"Coastal stations","g_Vegastöðvar":"Road stations","g_Ferðastaðir":"Travel locations","g_Allar stöðvar":"All stations","g_Aðrar stöðvar":"Other stations","g_Ãsafjarðardjúp":"Ãsafjarðardjúp","g_SkandinavÃa":"Scandinavia","g_Evrópa":"Europe","g_Miðjarðarhafið":"Mediterranean","g_N-AmerÃka":"North America"},"watermap":{"g_Rennslisstöðvar":"Water flow stations"},"df_detail_2l":"%DDD %DD.%MM<br/>%hh:%mm GMT","df_day_date":"%DDDD, %DD. %MMM.","df_daytime_simple":"%DDD %hh:%mm","df_slider_days":"%DDD<br/><span class=\"timi\">%D.%MMM %hh GMT</span>","df_hm_simple":"%h:%mm","df_hm":"%hh:%mm GMT","df_full":"%DD.%MM.%YYYY %hh:%mm GMT","df_full_2l":"%DD.%MM.%YYYY<br/>%hh:%mm GMT","met_for":"Meteogram for","met_already":"is already on the page.","met_makeerr":"If it does not appear here, then processing has failed.","met_forec":"Forecast map","met_obs":"Observation map","met_notavail":"An automatic forecast is not produced for","met_notavail2":"The meteogram does not exist for the station","met_st_notfound":"Weather station not found","qua_shown":"Earthquakes shown","qua_all":"All earthquakes","qua_1p":"Magnitude 1 and larger","qua_2p":"Magnitude 2 and larger","qua_3p":"Magnitude 3 and larger","qua_date":"Date","qua_time":"Time","qua_lat":"Latitude","qua_lon":"Longitude","qua_depth":"Depth","qua_size":"Magnitude","qua_quality":"Quality","qua_place":"Location","qua_qtable":"Earthquake table","qua_qref_word":"of","qua_sum_title":"Earthquake count:","qua_sum_all":"Total","qua_sum_0":"Magnitude less than 1 in all","qua_sum_1":"Magnitude 1 to 2 in all","qua_sum_2":"Magnitude 2 to 3 in all","qua_sum_3":"Magnitude more than 3 in all","qua_total":"Total earthquakes",watflow:{1:"Very little flow",2:"Very little flow",3:"Little flow",4:"Normal flow",5:"Much flow",6:"Very much flow",7:"Very much flow",def:"Flow unknown"},wat_flowmtit:"Stream flow ratio",wat_flow:"Stream flow",wat_percip:"Stream flow ratio",wat_hpercip:"Maximum water level ratio",wat_stations:"Stream flow stations",wat_expl_map:"Explanations for hydrological map",wat_area:"Catchment area",wat_fpfoot:"The map shows the newest<br/>measurements of each station",wate_ice:"Ice hinders measurements",aval:{maptit:"Notices on avalanches last ten days",mapfoot:"Most notices come from<br> regions where avalanche<br> observers work.",expl_map:"Explanation for the avalanche map",warnword:"More avalanches are likely to have fallen without being reported",inacc_map:"Location on map is inaccurate",df_day:"%DD. %MMM. %YY",df_hour:"%hh:%mm",size:"Size",num:"Number",place:"Place",distr:"District",type:"Type",reason:"Reason",byhuman:"Caused by human",unknown_date:"Unknown",date:"Date",time:"Time",channel:"Channel",region:"Region",area:"Area",loc_rem:"Loc. remark",rem:"Other",perish:"Perished",injured:"Injured",uninjur:"Uninjured",road_clo:"Run over road",damage:"Damage",onmap:"Map",click_more:"Click for more information",more_to_come:"Further information will be added later"},avaltype:{0:"Avalanche",1:"Dry slab avalanche",2:"Wet slab avalanche",3:"Dry loose snow avalanche",4:"Wet loose snow avalanche",5:"Slush avalanches",6:"Powder avalanche",7:"Flood",8:"Slab avalanche",9:"Loose snow avalanche",10:"Landslide",11:"Landslide",12:"Rockfall",13:"Rock gel",14:"Ice avalanche",15:"Icefall",99:"Event",def:"Unknown type",unspec:"Unspecified"},avalreason:{1:"Intense rain and thaw",2:"Intense rain with out thaw",3:"Great amount of accumulated percipitation",4:"Intense thaw",5:"Run up of water above barrage",6:"Earthquake",7:"Eruption",8:"Frost and thaw",9:"By human",10:"Subvert by material",11:"Material overload",12:"Explosion",13:"By human, purposely","-99":""},avalDistr:{F:"Faxaflói",B:"Breiðafjörður",VF:"West fjords",VN:"Northern West fjords",NV:"North West",NT:"Tröllaskagi",NA:"North East",AG:"Eastern coastal area",A:"East fjords",AM:"Middle East fjords",SA:"South East",S:"South",M:"Central highlands"},ice_view_s:"View coordinates for ice bergs",ice_view_e:"View coordinates for ice edge",aurora:{likely_tit:"Aurora forecast for",idx_tit:"The night %1 to %2",not_avail:"<span class=\"detailinfo\">Text forecasts for auroras is not available for selected time period.</span>",act0:"Minimum",act1:"Quiet",act2:"Low",act3:"Moderate",act4:"Active",act5:"High",act6:"Very high",act7:"Strong",act8:"Severe",act9:"Extreme",dark:"Dark",nodark:"Not dark",sunrise:"Sunrise",sunset:"Sunset",moon0:"Not visible",moon1:"Visible all night",moon2:"Moon rises %1",moon3:"Moon sets %1",moon4:"Rises %1 and sets %2",moon5:"Sets %1 og rises again %2"}}; Edited January 10, 2014 by iscode Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464721 Share on other sites More sharing options...
Ch0cu3r Posted January 10, 2014 Share Posted January 10, 2014 Doing a lazy match seems to work fine. Change the regex to preg_match_all("~VI.([^=]+)=\s*(\[?{.*?}\]?);~is", $data, $matches); Quote Link to comment https://forums.phpfreaks.com/topic/285199-preg_match_all-problem-2/#findComment-1464746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.