how can i collect all the data between each <a> and </b> and put them in an array ? <a>1234</b> <a>5678</b> <a>abcd</b> <a>efgh</b> <a>ijkl</b> <a>mnop</b>
<?php $data = '<a>1234</b> <a>5678</b> <a>abcd</b> <a>efgh</b> <a>ijkl</b> <a>mnop</b>'; preg_match_all("|<[ba]>(.*)</[ba]>|Ui", $data, $matches); $array = $matches[0]; // $array now contains all the elements content ?> PHP:
^^ I wrote a huge function to do this that used complex math to calculate string lenghts , extracted the start and end positions of the string and returned a array. Sometimes I make things harder for myself it seems although it was handy for learning string manipulation , great bit of code .