base64 Decode

Hi All

I’m doing DB query and the result is base64 encoded so to display the result I do the following:

[php]$mailno = base64_decode($dbsid2);[/php]

Which gives me the result : a:1:{s:3:“url”;s:19:“[email protected]”;}

How do I display only the email address?

Thank you!

Tried decode and encode and just get the mail so my guess is that database does not simply has the email adress encoded.

anyhow if this is always the input and the email is always the last then this works

[php]$mailno = “: a:1:{s:3:‘url’;s:19:‘[email protected]’;}’”; //$mailno = : a:1:{s:3:‘url’;s:19:‘[email protected]’;}’
$mailno = end(explode(":", $mailno)); //$mailno = ‘[email protected]’;}’
$mailno = substr($mailno, 1, -4); //$mailno = [email protected] [/php]

end: takes the last value in the array.
explode: explodes the string at the : and makes it an array.
substr: remove the first charachter (the ') and the last 4 chracters (the ‘;}’).

against note that this only works if the format of $mailno is always the same.

my test to test encode:
[php]<?php
$mail = "[email protected]";
echo “mail =” . $mail . “
”;

$mailenc = base64_encode ($mail);

echo “mail encoded =” . $mailenc . “
”;
$maildec = base64_decode($mailenc);

echo “mail decoded =” . $maildec . “
”;
?>[/php]

Thank you, Jkwakkel!

The output is always the same so your solution works perfect :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service