我想從使用fgets和substr逐行循環的Isam文件中分離數據,以從正確的行位置獲取正確的數據。PHP:使用substr時刪除多餘的空格
源數據:
000000124325424Productname Type Price Weight Unit Unitcode
000000124325324Productname2 Type2 Price2 Weight2 Unit2 Unitcode2
問題是,SUBSTR不recocnize數據,因此數據的位置是變化的每一行之間的那些多餘的空格。
SUBSTR是「看到」一行:
000000124325424Productname Type Price Weight Unit Unitcode
有什麼辦法來保護項目之間的空間?
你想要'substr'? – davidkonrad
例如:產品代碼 $ row。= ltrim(trim(substr($ line,0,16)),'0'); –