I have an associative array. In this array some keys have prefix “suf_”. how I create a new array with these suffixed key and value? see the example below
Array
(
[buildings_sum] =>
[accidental_damage] => 0
[landslip_cover] => 0
[loss_of_rent] =>
[loss_period] =>
[contents_sum] =>
[suf_household_contents_sum] =>
[damage_cover] => 0
[suf_tobacco_stock_sum] =>
[stock_sum] =>
[suf_buisness_interruption] => gb
[suf_buisness_interruption_indemnity] => 24 Months
[suf_increased_cost] => vb
[suf_increased_cost_indemnity] => 24 Months
[employer_liability] => 0
[liability_sum] => 2000000
[property_owner_liability] => 1000000
[goods_sum] => hvb
[freezer_stock] => bv
[money_night_safe] => vb
[money_locked_safe] => bv
[money_not_locked_safe] => cv
[private_dwelling_money] => fcv
[suf_change_machine_money] => cfv
[suf_gaming_machine_money] => 0
[personal_accident] => cfv
[glass] => cv
[book_debts] => cv
[suf_cover_guest] => 0
[terrorism_cover] => 0
[legal_expenses_cover] => 0
[loss_of_licence] => 0
[risks_cover] => 0
[voluntary_excess] => 250
[compulsory_excess] => h
)
Use a
foreachloop andpreg_match. Here is a working example with youd data as an example.