3

I wrote this to create Buynow button urls, but the url isn't coming out correctly.

It has something to do with imploding the array.. I guess

The problem is occurring here:

amount=10.00¤cy_code=USD

<?php
#
#   Paypal Buynow Button Url
#

$params = array(
    'cmd'       => '_xclick',
    'business'  => 'someone@gmail.com',
    'item_name' => 'Product',
    'amount'    => '10.00',
    'currency_code' => 'USD',
    'return' => 'http://www.stackoverflow.com',
);

$encoded_params = array();

foreach ($params as $k => $v){

    $encoded_params[] = $k.'='.urlencode($v);
}

echo $url = "https://www.paypal.com/cgi-bin/webscr?".implode('&', $encoded_params);

?>
AndrewFerrara
  • 2,383
  • 8
  • 30
  • 45

1 Answers1

3

&curren; is an HTML special character. If you are echoing to an HTML page, when you implode, use implode('&amp;',$encoded_params).

That should fix the issue.

keithhatfield
  • 3,273
  • 1
  • 17
  • 24