String appears to be valid JSON, but `json_decode()` returns NULL

前端 未结 5 1118
感动是毒
感动是毒 2020-12-19 08:31

I think I\'ve found where the error lies:

    $convertJSON = file_get_contents(\"http://www.google.com/ig/calculator?hl=en&q=\" . $currencyValue . $curre         


        
5条回答
  •  [愿得一人]
    2020-12-19 09:14

    strip it of everything but decimal points, commas, and numbers, and give me a result.

    Actually you do the exact contrary with your regex. Add a ^ after [: [^ to negate it

    $currencyValue = preg_replace('/([^0-9\.,]+)/', '', $currencyValue);
    

提交回复
热议问题