javascript - preg_replace create two different variables by spliting another one -


i using post xmlhttprequest in order send data php script. part of javascript code this:

function phppost(a, b){     var hr = new xmlhttprequest();     hr.open("post", "phppostexample.php", true);     hr.setrequestheader("content-type", "application/x-www-form-urlencoded");     hr.send("send="+a+""+b); } 

and part of php code this:

if(isset($_post['send'])) {     $code = preg_replace('#[^0-9]#', '', $_post['send']);     $name = preg_replace('#[^a-za-z0-9]#', '', $_post['send']); 

the problem want 2 variables give (a , b), become $code , $name when run phppost(43365, "hello world 43"); php script gives me $code 4336943 , $name 43369helloworld43. how can make php scriipt give me $code 43369 , $name hello world 43 (with gaps between words)? in advance

really elaborating on @charlietfl's comment:

function phppost(a, b){     var hr = new xmlhttprequest();     hr.open("post", "phppostexample.php", true);     hr.setrequestheader("content-type", "application/x-www-form-urlencoded");     hr.send("code="+a+"&name="+b); } 

then

if(isset($_post['code'])) {     $code = $_post['code'];     $name = $_post['name']; } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -