Remplacer valeur vide dans un ARRAY
Posté : 06 nov. 2015, 15:17
Bonjour a tous.
j'ai crée une moulinette php pour exporter des données en CSv.
quand une valeur du tableau est vide j'aimerais la replacer une autre valeur.
en gros quand $Invoice_company_name n'est pas renseigné j'aimerais la remplacer par $Customer_Lastname ? une idée de la methode ??
merci d'avance
j'ai crée une moulinette php pour exporter des données en CSv.
quand une valeur du tableau est vide j'aimerais la replacer une autre valeur.
en gros quand $Invoice_company_name n'est pas renseigné j'aimerais la remplacer par $Customer_Lastname ? une idée de la methode ??
//création de ligne du futur csv
$lignes[] = array(
"$lettre_site".$Order_no ,
$Product_ID,
$Product_Ref,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Product_Name),
$Product_Price,
$Product_Quantity,
$Reduction_percent,
$Reduction_amount_tax_excl,
$Payment ,
$Total_discounts ,
$Total_products ,
$Total_shipping_tax_excl ,
$Rate_tax,
$Total_tax ,
$Total_paid ,
$Total_paid_real ,
$Invoice_date ,
$Delivery_date ,
$Date_added ,
$Date_updated ,
$Total_products_with_tax,
$lettre_site,
$Customer_no ,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Name_carrier),
$Customer_Firstname ,
$Customer_Lastname ,
$Customer_Email ,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_address_line_1 ),
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_address_line_2 ),
$Delivery_postcode ,
$Delivery_city ,
$Delivery_phone ,
$Delivery_phone_mobile ,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_vat_number ),
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_dni ),
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Name_state ),
$Name_country,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_company_name ),
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Invoice_address_line_1 ),
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Invoice_address_line_2 ),
$Invoice_postcode ,
$Invoice_city ,
$Invoice_phone ,
$Invoice_phone_mobile ,
$Invoice_firstname ,
$Invoice_lastname ,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Invoice_company_name ),
$Name_iso ,
$Customer_gender ,
$Customer_date_add ,
$Customer_date_upd ,
str_replace( array( '<br>', '<br />', ';', "\n", "\r", chr(10),chr(13) ), array( '-', '-', '-', '-', '-', '-' , '-' ), $Delivery_detail )
);
merci d'avance