Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从json输出中删除分号_Php_Drupal - Fatal编程技术网

Php 从json输出中删除分号

Php 从json输出中删除分号,php,drupal,Php,Drupal,我有一个从json对象读取的$object。我正在使用\u filter\u url()函数在drupal中将文本显示为url 只要有1个以上的url,它就会在第一个url的末尾显示分号。我如何删除它?这意味着我希望URL以及分号下没有超链接 function test($object){ echo str_replace('; ','',$object); //this removes the ; but I need the semicolon also to be di

我有一个从json对象读取的
$object
。我正在使用
\u filter\u url()
函数在drupal中将文本显示为url

只要有1个以上的url,它就会在第一个url的末尾显示分号。我如何删除它?这意味着我希望URL以及分号下没有超链接

function test($object){
    echo str_replace('; ','',$object);  //this removes the ;   but I need the semicolon also to be    displayed without any hyperlink below it. 
}

function test($object) {
    $x = explode(';',$object);
    for($i=0;$i<count($x);$i++) {
        echo _filter_url($x[$i]);   //even this removes the semicolon, but i want the semicolon to be    displayed at the middle of multiple urls, however the semicolon should not have the hyperlink under
    }
}
功能测试($object){
echo str_replace(“;”,“$object);//这将删除;但是我需要分号也显示出来,并且在下面没有任何超链接。
}
功能测试($object){
$x=分解(“;”,$object);
对于($i=0;$i请尝试以下方法:

trim($object, '; ');
请参见,这将仅从字符串的开头或结尾删除“”和“;”


还请注意,$object可能是如果它实际上是一个字符串,您可能会想到的最糟糕的变量名。

在示例代码和描述中使用$object使这一点更难理解(因为它似乎与字符串有关).您应该向我们展示预期的输入、错误的输出以及您实际想要的。