lundi 2 mars 2015

use php variables for awk regex commands


trying to implement autosuggest using php. autosuggest list generated using awk



$input= $_GET["term"];
$suggest=array();
exec('awk \'BEGIN{FS=","}/.$input./{print $2,"-cost-",$1}\' 3.txt',$suggest);
echo json_encode($suggest);


in place of $input to test autosuggest i was using a charachrecter eg.A works fine. however i am not able to take a dynamic character as an input to awk. some thing wrong with .$input. cant figure out how to write the escape characters


thanks in advance



Aucun commentaire:

Enregistrer un commentaire