note 93375 modified in function.base64-encode by danbrown
| From: | danbrown@php.net | Date: | Sun, 06 Sep 2009 19:54:23 +0000 |
| Subject: | note 93375 modified in function.base64-encode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160264@lists.php.net to get a copy of this message | ||
Note that some applications, such as OpenSSL's enc command, require that there be a line break
every 64 characters in order for their base64 decode function to work. The following function will
take care of this problem:
<?php
function ($encodeMe) {
$data = base64_encode($encodeMe);
$datalb = "";
while (strlen($data) > 64) {
$datalb .= substr($data, 0, 64) . "\n";
$data = substr($data,64);
}
$datalb .= $data;
return $datalb;
}
?>
--was--
Note that some applications, such as OpenSSL's enc command, require that there be a line break
every 64 characters in order for their base64 decode function to work. The following function will
take care of this problem:
function ($encodeMe) {
$data = base64_encode($encodeMe);
$datalb = "";
while (strlen($data) > 64) {
$datalb .= substr($data, 0, 64) . "\n";
$data = substr($data,64);
}
$datalb .= $data;
return $datalb;
}
http://php.net/manual/en/function.base64-encode.php