Reputation: 10907
This is my array of bytes:
var $x = [108,181,183,176,140,239,53,105,104,47,47,21,147,67,96,87,175,35,67,97]
It has a binary PHP equivalent of gibberish: $x = "lµ·°Œï5ih//“C``W¯#Ca";
Now, what I can use so that javascript:btoa(SOME_ENCODING_FUNCTION($x));
perfectly matches <?php base64_encode($x); ?>
?
Thank you!
Upvotes: 1
Views: 1006
Reputation: 664434
String.fromCharCode.apply(null, $x);
will return the string to use in btoa
.
Upvotes: 4
Reputation: 10874
You can use base64_encode function but the javascript version of it
http://phpjs.org/functions/base64_encode:358
PHP JS is a good project that aims to port PHP functions to javascript, so if you ever need a javascript function that does exactly the same as a PHP function googling "phpjs _function_name_" will often give you what you are after :)
Upvotes: 1