2015-12-15 28 views
2

我已經通過腳本將.xlsx文件導入到PHP。我只需要文件中的兩列 http://imgh.us/xlsxx.png計算空格直到PHP數組中的下一個字符串

這樣做,但正如您所看到的那樣,有地址並在其後面有空格。 我需要從右欄的信息在一個字符串對應的左側地址。

foreach ($Reader as $Row) 
    { 
     array_push($data, $Row); 
     $aadress_loc = array_search("Aadress", $Row); 
     $eluruumid = array_search("Ehitise osad", $Row); 
     array_push($asukohtruumid, $aadress_loc); 
     array_push($asukohtruumid, $eluruumid); 
    } 
    $li_length = count($data); 
    for ($i = 1; $i < $li_length; $i++){ 
     array_push($aadress_mas,($data[$i][$asukohtruumid[0]])); // left column 
     array_push($ruumid_mas,($data[$i][$asukohtruumid[1]])); // right column 
    } 

Array 
(
[0] => Harju maakond, Kernu vald, Laitse küla, Lossi tee 6 
[1] => 
[2] => // 0;2 is the length of the first element 
) 
Array 
(
[0] => E/1;E/2;E/3;E/4;E/5;E/6;M/7/Kontoriruumid;E/8;E/9 
[1] => E/10;E/11;E/12;E/13;E/14;E/15;E/16;E/17;E/18;E/19 
[2] => E/20;E/21;E/22;E/23;E/24 
so I need to merge these 0;2 elements from another array to one string 
and repeat the process with another elements from aadress array. 

enter image description here

這裏是與diffrences的數組,但我不知道怎麼用它做什麼,我需要。 對不起,不太好的英語。

+0

也許檢查行是否爲空,如果(!empty($ Row)){//做些什麼,如果爲true} –

+0

我已經做了這個,並且我有數組,我有差異,但我已經與這整夜,我的思想工作得不好。這裏是一張圖片:http://imgh.us/13123.png – WKoppel

+0

我不太明白你想要做什麼,你能否多解釋一下。 –

回答

0

希望我理解這個問題,但我認爲你正在尋找這樣的:

foreach ($Reader as $Row) 
{ 
    echo $row[0].' - '.$row[7]; 

    // OR 

    echo $row['Aadress'].' - '.$row['Ehitise osad']; 
} 

我不知道哪一個會在你的情況下工作。

相關問題