Shiva
8 months ago

Converting string to ascii hex

Posted 8 months ago by Shiva

I'm trying to convert certain symbols in my string into ascii hex. I've been looking but I can't seem to find anything.

The string that I need converted is this

$success = url('payfast-success');
$cancel = url('payfast-cancel');

merchant_id=10000100&merchant_key=46f0cd694581a&return_url='.$success.'&cancel_url='.$cancel.'&m_payment_id=01AB&amount='.$total.'&item_name=Test Item&item_description=A test product&email_confirmation=1&[email protected]&payment_method=eft

and the output is suppose to look like this

merchant_id=10000100&merchant_key=46f0cd694581a&return_url=http%3A%2F%2Flaravel-shop.test%2Fpayfast-success&cancel_url=http%3A%2F%2Flaravel-shop.test%2Fpayfast-cancel&m_payment_id=01AB&amount=1.05&item_name=Test+Item&item_description=A+test+product&email_confirmation=1&confirmation_address=test%40test.com&payment_method=eft

This is what my output looks like at the moment

merchant_id=10000100&merchant_key=46f0cd694581a&return_url=http://laravel-shop.test/payfast-success&cancel_url=http://laravel-shop.test/payfast-cancel&m_payment_id=01AB&amount=1.05&item_name=Test Item&item_description=A test product&email_confirmation=1&[email protected]&payment_method=eft

Please sign in or create an account to participate in this conversation.