|
|||
|
Hallo!
Mein Lieferant bietet eine Preisliste als Textdatei zum Download an. Die erste Zeile beinhaltet die Feldbezeichnungen: Artikelnummer, Artikelbezeichnung, Artikelgruppe, Artikelgruppe, Artikelgruppe, Artikelgruppe, Artikelgruppe, EAN Nr., Hersteller Kurzname, Artikelkurzbeschreibung, Verf?gbarkeit Text, Verkaufspreis Wie kann ich diese Zeile so umschreiben, dass daraus die Feldbeschreibungen so aussehen: v_products_model, v_products_name_2, v_categories_name_1, v_categories_name_2, v_categories_name_3, v_categories_name_4, v_categories_name_5 v_products_ean, v_manufacturers_name, v_products_description_2, v_verfuegbarkeit_2, v_products_price Kann ich das ungef?hr so l?sen wie es Easypopulate mit EOREOR handhabt? Wie kann ich definieren, dass v_products_price als letztes Feld erkannt wird und somit EOREOR nicht mehr ben?tigt wird? Code:
// now we string the entire thing together in case there were carriage returns in the data
$newreaded = "";
foreach ($readed as $read){
$newreaded .= $read;
}
// now newreaded has the entire file together without the carriage returns.
// if for some reason excel put qoutes around our EOREOR, remove them then split into rows
$newreaded = str_replace('"EOREOR"', 'EOREOR', $newreaded);
$readed = explode( $separator . 'EOREOR',$newreaded);
// Now we'll populate the filelayout based on the header row.
$theheaders_array = explode( $separator, $readed[0] ); // explode the first row, it will be our filelayout
$lll = 0;
$filelayout = array();
foreach( $theheaders_array as $header ){
$cleanheader = str_replace( '"', '', $header);
// echo "Fileheader was $header<br><br><br>";
$filelayout[ $cleanheader ] = $lll++; //
}
unset($readed[0]); // we don't want to process the headers with the data
Gr??e tmj |
![]() |
| Lesezeichen |
| Stichworte |
| easypopulate, importfelder, umschreiben |
| Themen-Optionen | |
| Ansicht | |
|
|