次のテキストがあります。
We%27re%20proud%20to%20introduce%20the%20Amazing
PHPでエンコーディングを解除したいのですが、うまくいきhtml_entity_decode()
ません。
助言がありますか?
echo urldecode('We%27re%20proud%20to%20introduce%20the%20Amazing');
これは url_ecoded 文字列です。使用するurldecode
このエンコーディングは、パーセント エンコーディングまたは URL エンコーディングと呼ばれます。PHPrawurlencode
ではrawurldecode
、「生の」URL エンコーディング用のurlencode
とurldecode
、クエリで使用されるわずかに異なるエンコーディング用の があります ( application/x-www-form-urlencodedとして知られ、スペースが の+
代わりに でエンコードされます%20
)。
あなたの場合、「生の」URLエンコーディングが使用されています。だからrawurldecode
それをデコードしてみてください:
rawurldecode('We%27re%20proud%20to%20introduce%20the%20Amazing')
%27 と %20 は URL エンコードされたエンティティです。
これをデコードする には、use urldecode()を使用する必要があります。URL パラメータをエンコードするurlencode()も存在します。