I have this cookie which indicates 2 items split by /:
cookie packs = 10=BATTLEFIELD 2 + 1=20.00/10=BATTLEFIELD 2 + 1=20.00
$packs = explode("/", rawurldecode($_COOKIE["packs"]));
I need to decode it with urldecode()
, but when I do it I lose the + sign between BATTLEFIELD 2
and 1
, how can I avoid this?
Make use of rawurldecode()
. You won't lose the +
<?php
echo rawurldecode('10=BATTLEFIELD 2 + 1=20.00/10=BATTLEFIELD 2 + 1=20.00');
OUTPUT:
10=BATTLEFIELD 2 + 1=20.00/10=BATTLEFIELD 2 + 1=20.00
EDIT : [Since you changed the question]
<?php
$cookie_packs = '10=BATTLEFIELD 2 + 1=20.00/10=BATTLEFIELD 2 + 1=20.00';
$packs = explode("/", rawurldecode($cookie_packs));
var_dump($packs);
array (size=2)
0 => string '10=BATTLEFIELD 2 + 1=20.00' (length=26)
1 => string '10=BATTLEFIELD 2 + 1=20.00' (length=26)