php - Converting array to string -
I have a cart php page where I display client products. In the same page I have a form that sends the client's personal information such as name, surname, etc., but sends product information such as product name, statue, etc. directly to my email address.
Now, the problem is that when I send the form, I get all the information at my email address, but not the product details, for example, I have an ARRAY in the order email on the product name field.
I think there is a problem in changing the array to string but I do not know that I tried some examples but none of them works. I have put my code that i think my problem is 'Echo' '; Echo '';
echo '& lt; Input type = "hidden" name = "product_name ['. $ Cart_items.']" Value = "'. $ Obj-> product_name.'" / " '; Echo '& lt; Input type = "hidden" name = "itemcode ['. $ Cart_items.']" Value = "'. $ Product_code." "/> '; Echo' & lt; input type =" hidden "name =" item_desk ['. $ Cart_items '] "Value ="' $ Obj- & gt; Product_desc. "/" Gt; Echo '& lt; Input type = "hidden" name = "item_kit ['. $ Cart_items.']" Value = "'. $ Cart_itm [" qty "]." "/" Gt; $ Cart_items ++; Echo '& lt; Input type = "submit" value = "submit" & gt; '; `Function clean_string ($ string) {$ bad = array (" content-type "," bcc: "," to: "," cc: "," href "); Return str_replace ($ Bad, "", $ string); $ product_name_string = implode ("", $ cart_items); }
$ email_message = "Nume:" .clean_string ($ name1). "\ N"; $ Email_message = "E-mail:" .clean_string ($ email1) "\ N"; $ Email_message = "Cos:" .clean_string ($ product_name_string) "\ N"; I need some help. Please use the basic PHP: string reference array will only be the word of the word array .
For example
$ foo = array ('a', 'b', 'c'); Counterfeit $ foo; The word array , no a, b, c or anything else will be printed.
Your input field, telling PHP, should be treated as an array:
& lt; Input type = "text" name = "itemcode [foo]" ... ^ ----- - Therefore $ _ POST ['item_code'] < / Code> will automatically be an array if you want content of those arrays to be present in your email, then something like this will happen:
$ item_codes = implode (',', $ _POST [ 'Item_code']);
Comments
Post a Comment