2012-03-22 57 views
0

删除内容我从包含如何从页面在PHP

<?xml version="1.0" encoding="UTF-8"?> 
<ipinfo xmlns="http://data.quova.com/1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"> 

我想删除这个头 因此需要帮助该怎么做了卷曲的一页。

我试过str_replace函数的功能,但没有成功

$find1='/<?xml version="1.0" encoding="UTF-8"?>/'; 
$find2='/<ipinfo xmlns="http://data.quova.com/1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">/'; 
$contentx = str_replace($find1, '', $data,$count); 
+1

无需在'str_replace'分隔符,它不是一个正则表达式功能 – 2012-03-22 20:00:58

+0

为什么你'/'的前/后前引号? – 2012-03-22 20:01:44

+0

如果删除了正则表达式分隔符,'str_replace()'应该成功。 – 2012-03-22 20:01:51

回答

0

你并不需要使用“/ /”分隔符与str_replace函数,只能用正则表达式的功能。在开始和结束时删除斜杠。

换句话说:

$find1='<?xml version="1.0" encoding="UTF-8"?>'; 
$find2='<ipinfo xmlns="http://data.quova.com/1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">'; 
$contentx = str_replace($find1, '', $data,$count); 
+0

感谢它帮助我:) – user114500 2012-03-22 21:00:06

0

您可以使用explode()功能做的更容易。

$dataArray = explode("\r\n", $data, 3); // adjust the delimiter if it's unix newline 
$contentx = $dataArray[2];