echo output data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

echo output data

Post by Supplement »

If I'm using this <?php echo $product_qty;?> to echo the output of the products and there is multiple products they are delimited by a comma, is it possible to delimit by a dash or basically anything I want for the ouput?


right now the out put would be this.

product ids"

13, 42, 33, 6


Could i get the output like so?

13 - 42 - 33 - 6

or possibly just get rid of the commas from the output? :)
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: echo output data

Post by AbraCadaver »

mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

What's the syntax look like on that?

<?php echo str_replace('-',$product_qty');?>

Something like this I suppose, I tried it but no bueno.
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: echo output data

Post by nowaydown1 »

Something like this should work for you:

Code: Select all

$product_qty = str_replace(", ", " - ", $product_qty);
echo $product_qty;
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

Still left a comma in between the products ordered.
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

Still looking for a bit of help on this fix, if anybody has ideas. Thanks in advance.
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

If I'm using this tracking pixel on the thank you page after customers check out, I was wondering if I could change the output completely.

This is the pixel on the page before a checkout.

<img src="https://www.site.com/u?CID=1521148&TYPE ... TEM1=<?php echo $product_id;?>&AMT1=<?=$_SESSION[tracker_order_amt]?>&QTY1=<?php echo $product_qty; ?>&DISCOUNT=0" height="1" width="20">


After a checkout has been completed, it's something like this:

<img src="https://www.site.com/u?CID=1521148&TYPE ... 4&ITEM1=15, 24, 36&AMT1=336.00&QTY1=4, 1 , 3&DISCOUNT=0" height="1" width="20">


Below is the output that I'd Ideally want.


&ITEM1=15
&AMT1=112.00
&QTY1=4

&ITEM2=24
&AMT2=112.00
&QTY2=1

&ITEM3=36
&AMT3=112.00
&QTY3=3



Any help would be greatly appreciated.
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

up? :banghead:
malakiahs
Forum Newbie
Posts: 13
Joined: Tue Sep 13, 2011 11:15 am

Re: echo output data

Post by malakiahs »

Have you tried?

implode('- ' , $product_qty);
User avatar
Supplement
Forum Commoner
Posts: 45
Joined: Thu Aug 18, 2011 8:52 pm
Location: Oceanside, CA

Re: echo output data

Post by Supplement »

No, but I'll give that a try.

What about the question mentioned above your post? Ideas?

:D
Post Reply