php - json_decode returns null (special characters) WoW API -


i'm having issues json_decode. have form asks realm list , character name (which can have special letters such as: ö, à, é, etc):

<form method="post">   <!--//<input name="realm" type="search" id="realm" value="<?php echo $_post['realm']; ?>"><br />-->     <div class="styled-select">     <select name="realm" required>       <option value="" <?php if ($selected_choice == "none") { print "selected='selected'"; }?>>select...</option>       <option value="aegwynn" <?php if ($selected_choice == "aegwynn") { print "selected='selected'"; } ?>>aegwynn</option>       <option value="area 52" <?php if ($selected_choice == "area 52") { print "selected='selected'"; } ?>>area 52</option>       <option value="arygos" <?php if ($selected_choice == "arygos") { print "selected='selected'"; } ?>>arygos</option>       <option value="caelestrasz" <?php if ($selected_choice == "caelestrasz") { print "selected='selected'"; } ?>> caelestrasz </option>       <option value="darrowmere" <?php if ($selected_choice == "darrowmere") { print "selected='selected'"; } ?>> darrowmere </option>       <option value="dath'remar" <?php if ($selected_choice == "dath'remar") { print "selected='selected'"; } ?>>dath'remar</option><!--'-->       <option value="drakkari" <?php if ($selected_choice == "drakkari") { print "selected='selected'"; } ?>> drakkari </option>       <option value="dreadmaul" <?php if ($selected_choice == "dreadmaul") { print "selected='selected'"; } ?>> dreadmaul </option>       <option value="frostmourne" <?php if ($selected_choice == "frostmourne") { print "selected='selected'"; } ?>>frostmourne</option>       <option value="gnomeregan" <?php if ($selected_choice == "gnomeregan") { print "selected='selected'"; } ?>>gnomeregan</option>       <option value="gorgonnash" <?php if ($selected_choice == "gorgonnash") { print "selected='selected'"; } ?>>gorgonnash</option>       <option value="illidan" <?php if ($selected_choice == "illidan") { print "selected='selected'"; } ?>>illidan</option>       <option value="khaz'goroth" <?php if ($selected_choice == "khaz'goroth") { print "selected='selected'"; } ?>>khaz'goroth</option><!--'-->       <option value="maiev" <?php if ($selected_choice == "maiev") { print "selected='selected'"; } ?>> maiev </option>       <option value="quel'thalas" <?php if ($selected_choice == "quel'thalas") { print "selected='selected'"; } ?>> quel'thalas </option><!--'-->       <option value="ragnaros" <?php if ($selected_choice == "ragnaros") { print "selected='selected'"; } ?>> ragnaros</option>     </select>     <input name="char" style="none" type="text" size="20" id="char" value="<?php echo $_post['char']; ?>" required>   </div>   <br>   <input type="submit" name="submit" class="btn btn-warning" value="submit">  </form> 

here issue arising in php (i have made lot of comments have tried fix issue):

$url = 'https://us.api.battle.net/wow/character/' . $formrealm . '/' . $formchar . '?fields=items&locale=en_us&apikey=uv5rmcd7mk326pqxcy7hv79y3z97vwmr'; $result = file_get_contents($url); $url1 = 'https://us.api.battle.net/wow/character/' . $formrealm . '/' . $formchar . '?fields=stats&locale=en_us&apikey=uv5rmcd7mk326pqxcy7hv79y3z97vwmr'; $result1 = file_get_contents($url1); //echo $url;  // file_get_contents call instead $data = $result; $data1 = $result1;  // decode json $json = json_decode($data, true); //$json = preg_replace('/,\s*([\]}])/m', '$1', utf8_encode($url)); //$json = json_decode($json); $json1 = json_decode($data1,true); //$json1 = preg_replace('/,\s*([\]}])/m', '$1', utf8_encode($url1)); //$json1 = json_decode($json1); 

i found answer!

at top of html code forgot add in:

    <meta charset="utf-8"> 

hope helps issue this!


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -