Created
June 30, 2018 11:53
-
-
Save em7v/9b666987159bd23af01b7249fa778d05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mapReplaces = [ | |
'ORDER_ID' => 'MARGO' | |
]; | |
$text | |
= '<?xml version="1.0" encoding="utf-8"?> | |
<ShipOrderDocument xmlns="http://schemas.quietlogistics.com/V2/ShipmentOrder.xsd" > | |
<ClientID>SKITHEEAST</ClientID> | |
<BusinessUnit>SKITHEEAST</BusinessUnit> | |
<OrderHeader OrderNumber="{ORDER_ID}" OrderType="SO" OrderDate="{ORDER_DATE}" | |
ShipDate="{ORDER_DATE}"> | |
<Comments>{NOTE}</Comments> | |
<ShipMode Carrier="{SHIPPING_TITLE}" ServiceLevel="[Order???]"/>'; | |
$result = preg_replace_callback('/{(.*?)}/si', function ($match) use ($mapReplaces) { | |
if (isset($mapReplaces[$match[1]])) { | |
return $mapReplaces[$match[1]]; | |
} | |
}, $text); | |
dd($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment