我正在编写将索引数组更改为关联数组的代码。它适用于我检查过的所有州,加利福尼亚除外。对于 california,它暂时是一个关联数组,然后它突然变成一个索引数组,最后又变回一个关联数组。当我回显各个索引时,我得到了我希望在关联数组中使用的值,所以我不确定它为什么不粘住。任何人都可以帮忙吗?
$ids_file = file_get_contents("http://waterdata.usgs.gov/ca/nwis/current?index_pmcode_STATION_NM=1&index_pmcode_DATETIME=2&index_pmcode_72019=72&index_pmcode_00065=261&index_pmcode_00060=191&group_key=NONE&format=sitefile_output&sitefile_output_format=rdb&column_name=agency_cd&column_name=site_no&column_name=station_nm&column_name=dec_lat_va&column_name=dec_long_va&column_name=coord_acy_cd&column_name=dec_coord_datum_cd&column_name=alt_va&column_name=alt_acy_va&column_name=alt_datum_cd&sort_key_2=site_no&html_table_group_key=NONE&rdb_compression=file&list_of_search_criteria=realtime_parameter_selection");
$gages = explode("\t",$ids_file);
//this provides the randomized list of gages to pick from
for($i=19;$i<count($gages);$i=$i+9){
$gagenew = array($gages[$i]=>$gages[$i+1]);
$gagenum = array_merge($gagenum,$gagenew);
}
这是我回声时得到的一个小样本$gagenum
[09526200] => YPSILANTI CANAL NEAR WINTERHAVEN, CA
[09527590] => COACHELLA CANAL ABV ALL-AMERICAN CANAL DIV
[09527594] => COACHELLA CANAL NEAR NILAND, CA
[09527597] => COACHELLA CANAL NEAR DESERT BEACH, CA
[09527700] => ALL-AMERICAN CANAL BELOW DROP 2 RESERVOIR OUTLET
[09530000] => RESERVATION MAIN DRAIN NO. 4 NEAR YUMA, AZ
[09530500] => DRAIN 8-B NEAR WINTERHAVEN, CA
[0] => BOREHOLE SPG CHANNEL NR TECOPA HOT SPGS, CA
[1] => AMARGOSA RV AT TECOPA, CA
[2] => AMARGOSA RV ABV CHINA RANCH WASH NR TECOPA, CA
[3] => WILLOW CK AT CHINA RANCH, CA
[4] => SALT C NR MECCA
[5] => ALAMO R NR NILAND CA
[6] => NEW R AT INTERNATIONAL BOUNDARY AT CALEXICO CA
[7] => NEW R NR WESTMORLAND CA
[8] => SNOW C NR WHITE WATER CA
[9] => FALLS C NR WHITE WATER CA
[10] => WHITEWATER R A WINDY POINT MAIN CHANNEL CA
[11] => WHITEWATER R A WINDY POINT OVERFLOW CHANNEL CA
看看它在哪里突然变成了一个索引数组?