<?php $regex = '#\[element title=(.*)picture=(\d+)\](.*?)(\[caption\](.*)\[/caption\])?\[/element\]#i'; $text = '[element title=element title picture=32]Lorem ipsum dolor[caption]Photo by John Doe[/caption][/element]'; preg_match ( $regex, $text, $match ); print_r( $match );?>
Standard input is empty
Array ( [0] => [element title=element title picture=32]Lorem ipsum dolor[caption]Photo by John Doe[/caption][/element] [1] => element title [2] => 32 [3] => Lorem ipsum dolor [4] => [caption]Photo by John Doe[/caption] [5] => Photo by John Doe )
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!