PHP5:
http://php.net/manual/en/ref.dom.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> I have an xml document storing some data I need. What I want to do is this:
> 1. Scan to the end of the file.
> 2. Find the closing tag.
> 3. Insert a new entry in before the closing tag.
There are specific classes and functions in the PHP core that can help
you do just this.
> I've tried:
> 1.
This should get you started:
$old_data = file_get_contents('./test.txt');
$my_data = "foo bar";
$pattern = '/(.*)(<\/.*>)$/i';
$replacement = '$1' . $my_data . '$2';
$new_data = preg_replace($pattern, $replacement, $old_data);
echo $new_data;
or a little more succinctly
$my_data = "foo bar";
$n
This should get you started:
$old_data = file_get_contents('./test.txt');
$my_data = "foo bar";
$pattern = '/(.*)(<\/.*>)$/i';
$replacement = '$1' . $my_data . '$2';
$new_data = preg_replace($pattern, $replacement, $old_data);
echo $new_data;
or a little more succinctly
$my_data = "foo bar";
$n
4 matches
Mail list logo