是否可以更改对象元素的子字符串 在foreach循环内部的流程?所以我尝试但它不起作用。
$xml= '';
foreach ($objetcs as $object){
str_replace('searched','replacement', $object->link);
//then I would call a function to render my rss
$xml .=$object->renderRSS();
}
答案 0 :(得分:2)
str_replace
将返回字符串或数组,它不会更改原始变量,因此如果$object->link = str_replace('searched','replacement', $object->link);
为$link
public
答案 1 :(得分:2)
试试这个:
$xml= '';
foreach ($objetcs as $object){
$object->link = str_replace('searched','replacement', $object->link);
//then I would call a function to render my rss
$xml .=$object->renderRSS();
}
答案 2 :(得分:0)
尝试:
$object->link = str_replace('searched','replacement', $object->link);