Question

my data

this1

this2

this3

this4

what I want

$keepit[0]='this1';
$keepit[1]='this2';
$keepit[2]='this3';
$keepit[3]='this4';

data uri

data:text/plain;charset=utf-8;base64,dGhpczENCnRoaXMyDQp0aGlzMw0KdGhpczQ=

Is it possible to do this?

Était-ce utile?

La solution

You can do this with normal file methods using the data:// protocol:

$data = file('data://text/plain;charset=utf-8;base64,dGhpczENCnRoaXMyDQp0aGlzMw0KdGhpczQ=');

Alternatively though you can pull out the base64 encoded string and decode it yourself:

$plaintext = base64_decode('dGhpczENCnRoaXMyDQp0aGlzMw0KdGhpczQ=');

Autres conseils

If the encoded string can be decoded this will work:

$file_path = ''; // change this.
$fp = fopen($file_path, 'rb');
$contents = fread($handle, filesize($file_path));
fclose($fp);
$data_uri = preg_split('/,/', $contents);
$encoded = $data_uri[1];
$decoded = base64_decode($encoded);
var_dump($decoded);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top