I want to write a function in php which can extract all the text withing given html string and tag.
something like this:
function signature
function HTMLTextExtrator(htmlString, tagName)
return type : string
Example:
$string=<body><div>this is a <p>text</p> to be extracted</div></body>
echo HTMLTextExtrator($string,p); // output: text
echo HTMLTextExtrator($string,div); // output: this is a <p>text</p> to be extracted
echo HTMLTextExtrator($string,body); // output:<div>this is a <p>text</p> to be extracted</div>
If anyone know what code can be inside the function to execute this....thanx