Edit a page

I can view the contents of a file using…

$svg = show_source('racks/cabinet_'.$rack_id.'.php');
echo $svg;	

How do I add some code just after the second


(just before all the)


this seems like the function I want

But how can I specify where to put the code?

Not sure if it’s the best solution but just an idea:
You could explode the contents of the file by line:

$lines = explode(PHP_EOL, $fileContents);

and then use array_splice to insert lines where ever you want,
and finally implode back the lines:

$fileContents = implode(PHP_EOL, $lines);

I don’t think you want to use show_source aka. highlight_file. Though it may display as XML, it does not return XML. It returns some characters converted to entities. eg &lt; instead of <

If splitting into an array won’t work for you, you should be able to use “reader” and “writer” as long as you are working with valid non-entitized XML.



1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.