php: replace text in xml doc
php: replace text in xml doc
Out of context: Reply #20
- Started
- Last post
- 27 Responses
- vaxorcist0
3 possible methods:
1. $string = str_replace("hello","whatever new stuff",$string);
this will globally change hello to whatever new stuff, in the whole file, all at once2. open and loop through:
$rows = file("file.xml");
for($i=0;$i<sizeof($rows);$i++){
$this_row = $rows[$i];
// do stuff, use if/else/etc
}
// write output string to file3. use a library, ideally a good idea but may take more time to learn the library than to hack out a few lines of code
4. use a text-editor if it's a one-time thing....