Stack Overflow Asked by Burhan on January 1, 2022
Orignal String:
$string = "Home/Gallery/Images/Mountains";
Then I encode this string into base64_encode():
echo base64_encode($string);
Output:
SG9tZS9HYWxsZXJ5L0ltYWdlcy9Nb3VudGFpbnM=
But I want to show this output:
SG9tZS9H/YWxsZXJ5L0lt/YWdlcy9Nb3V/udGFpbnM=
↑
Look at the Slashes
means I don’t want to that base64_encode() never encode a slash "/" and show slash in orignal form but other string always convert into base64_encode()
There is someone here who can answer me and please also tell how to decode?
(Sorry for bad english)
You can split it and use the single parts to encode. You can not exclude any chars.
Note, you will gain some extra padding bytes!
$string = "Home/Gallery/Images/Mountains";
echo join('/', array_map(fn($v) => base64_encode($v), explode('/', $string)));
SG9tZQ==/R2FsbGVyeQ==/SW1hZ2Vz/TW91bnRhaW5z
Answered by Markus Zeller on January 1, 2022
0 Asked on December 26, 2020 by james-lin
1 Asked on December 25, 2020 by vince
2 Asked on December 25, 2020 by nck_505
2 Asked on December 25, 2020 by outofworld
0 Asked on December 25, 2020 by rob-edlin
2 Asked on December 24, 2020 by frank-nocke
1 Asked on December 24, 2020 by nguyn-tng
0 Asked on December 24, 2020 by judson-abraham
1 Asked on December 24, 2020
active directory az azure azure active directory permissions
0 Asked on December 24, 2020 by thor_
1 Asked on December 23, 2020 by hillinharwich
3 Asked on December 23, 2020 by holly-wong
0 Asked on December 23, 2020 by aaron-waller
1 Asked on December 23, 2020 by diamondjoe12
2 Asked on December 23, 2020 by david-browning
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP