$re = '/\[buyer_(?:email|mobile|fullname|address)\] =>\s*\K.*/m';
$str = 'SimpleXMLElement Object
(
[error_code] => 00
[token] => 1182263526325de72aw828369e7aa
[description] => SimpleXMLElement Object
(
)
[transaction_status] => 00
[receiver_email] => myemail@gmail.com
[order_code] => 3212423
[total_amount] => 200
[payment_method] => SimpleXMLElement Object
(
)
[bank_code] => NLAZ
[payment_type] => 1
[order_description] => SimpleXMLElement Object
(
)
[tax_amount] => 0
[discount_amount] => 0
[fee_shipping] => 0
[return_url] => success.php
[cancel_url] => order.php
[buyer_fullname] => eric phuong
[buyer_email] => eric@domain.com
[buyer_mobile] => 012108609
[buyer_address] => abc
[affiliate_code] => SimpleXMLElement Object
(
)
[transaction_id] => 12345
)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php