2017-03-01 77 views
-1

我的代碼得到的文本文件隨機行: 更新代碼:如何從最終刪除空空間

<?php 
$text = file_get_contents('proxy'); 
$textArray = explode("\n",$text); 
$randArrayIndexNum = array_rand($textArray); 
$randPhrase = $textArray[$randArrayIndexNum];?> 
<html> 
<body> 

<?php 
echo trim($randPhrase,"<br>"); 
?> 

</body> 
</html> 

但隨機文本對最終空間:

89.38.146.26:8080 <- here 

如何去除它?

+4

使用'trim()'去除空格。 –

+0

可能的重複:http://stackoverflow.com/questions/5704731/how-can-i-remove-space-at-the-end-of-string – Ruby

+0

@prakash坦克在哪裏我把修剪的代碼請?我不知道 –

回答

0

使用trim從字符串的開始和結尾刪除空白,或者使用rtrim僅從字符串末尾刪除空格。

+0

在哪裏我把修剪的代碼請?我不知道 –

+0

你看過我鏈接到的文檔嗎? – arieljannai

+0

是的,我檢查,但不能得到它的工作。我更新後的代碼 –