I am trying to make this function that extracts text from html for multiple steps but I cant figure out how to make a loop form it.
This is the task. I have this array
$arr = array("<div>" => "</div>", "<p>" => "</p>", "<h3>" => "</h3>");
The existing working function cut($a, $b, $c)
that gets the content in between in this case $a = "<div>", $b="</div>" and $c = the html
.
What i am trying to do is to make this:
- Step 1 - cut from div to div
- Step 2 - foreach results from step1, cut from p to p
- Step 3 - foreach results from step2, cut from h3 to h3
- Step n where n is array length.
Although I know that I can use foreach to get the results and apply step two, I cant generalize this.
EDIT
I have an existing function called cut
that has been described above. I want to create a new function called cutlayer($arr, $html)
where $arr is arr from above. I need the cutlayer function to use the cut function and do the following steps mentioned above but I cant figure out how to do that.
Thanks