简体   繁体   English

str_replace / trim无法从网址中正确删除空格

[英]str_replace/trim is not properly remove space from url

Well, I'm trying to sending message to my user based on my uploaded docx file. 好吧,我正在尝试根据上传的docx文件向用户发送消息。 In this docx file there are few number exists. 在此docx文件中,几乎没有数字。 Like: 880167xxxxxxx, 880167xxxxxxx etc.. 像:880167xxxxxxx,880167xxxxxxx等。

So to send sms i'm using following api link structure: 因此,要发送短信,我正在使用以下api链接结构:

require_once("file.php");       
$docObj = new DocxConversion("$file");
$docText= $docObj->convertToText();
$foo = preg_replace( '/\s+/', ' ', $docText ); 

$sms =  "http://fahimit.com/smsapi.php?user=xxx&pass=xxx&phone=$foo
senderid=$sender&message=$msg";
$sms = file_get_contents($sms);

but it's not sending sms it's BECAUSE when i output $foo it's contain space to left and right side of the number. 但是它没有发送短信,这是因为当我输出$ foo时,它的左边和右边都包含空格。 So for that reason i used trim and preg_replace, str_replace but NO LUCK. 因此,出于这个原因,我使用了trim和preg_replace,str_replace但没有运气。

So what can i do to send sms without any space in this url $sms ? 那么,我该怎么办才能在此$ sms URL中发送没有空格的短信

You have replaced space with space. 您已用空间替换了空间。 Use this one: 使用这个:

$foo = preg_replace( '/\s+/', '', $docText ); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM