|
Get data between 2 elements or tags |
|
Retrieves data from between 2 specified beginning and ending elements
or tags. Could be used to read data out of an xml document.
-
<?php
-
function find($string,$opener,$closer)
-
{ $part1 = explode($opener, $string);
-
$part2 = explode($closer, $part1[1]);
-
$result = $part2[0];
-
return $result;
-
}
-
-
// Example for use:
-
$string = "<data>Here is stuff</data>"
-
$data = find($string,"<data>","</data>"); // would set $data to "Here is stuff".
-
?>
|