Update Space to Hyphen in URL Using Php Get Method -


i update space hyphen in php url file via method. have tried methods, got error.

for example, original url pindtrict.php?ste=tamil nadu

i want optimized url as, pindtrict.php?ste=tamil-nadu

how this? here code,

<?php include(config.php'); $state_content= ""; $qry = "select distinct state_n pin_data order state_n asc"; $result = mysql_query($qry); while($row = mysql_fetch_array($result))     {         $state_content .= "<li><a href='pindtrict.php?ste=".$row['state_n']."'> ".$row['state_n']."</a></li>";     } mysql_close(); ?> <!doctype html> <html lang="en"> <head> <title>pincode directory</title> <body> <div>     <?php echo $state_content; ?><br /> </div> </body> </html> 

use

$state_content .= "<li><a href='pindtrict.php?ste=".str_replace(' ', '-',$row['state_n'])."'> ".$row['state_n']."</a></li>";