I need to extract text from a long string that has extra text within square brackets:
[vc_row][vc_column width="1/1"]28/04/2015 Text description[vc_row][vc_column width="1/1"][vc_row][vc_column width="1/1"]29/04/2015 Text description 2[vc_row][vc_column width="1/1"]
To extract the text and exclude the content inside the square brackets i apply this:
$page_content = preg_replace("/\[([^\[\]]++|(?R))*+\]/", "", $page->post_content);
Until here, it works. Now i can output my result and i see my string printed within tags:
<p>28/04/2015</p><h3><a>description</a></h3>
<p>29/04/2015</p><h3><a>description 2</a></h3>
But i need to create an array of the text i'm extracting, like this:
Array (
[0] => [28/04/2015]
[1] => [description]
[2] => [29/04/2015]
[3] => [description 2]
)
Or also
Array (
[0] => Array (
[0] => [28/04/2015]
[1] => [description]
)
[1] => Array (
[0] => [29/04/2015]
[1] => [description 2]
)
)
How to do this?
`, `
` etc.
– anubhava Jun 10 '15 at 09:25