çok boyutlu diziye dize dönüştürme

0 Cevap php

I'd like to convert this string:

$credit_packages_string = "300,0.25|1000,0.24|3000,0.22|4000,0.20|5000,0.18|6000,0.16|7000,0.14";

Bu diziye:

 $credit_packages = array(  array( 'credit_amount'=> 300,
      'price_per_credit'=>0.25),
      array( 'credit_amount'=> 1000,
      'price_per_credit'=>0.24),
      array( 'credit_amount'=> 3000,
      'price_per_credit'=>0.22),
      array( 'credit_amount'=> 4000,
      'price_per_credit'=>0.20),
      array( 'credit_amount'=> 5000,
      'price_per_credit'=>0.18),
      array( 'credit_amount'=> 6000,
      'price_per_credit'=>0.16),
      array( 'credit_amount'=> 7000,
      'price_per_credit'=>0.14)
      );

en verimli şekilde bunu nasıl yapardınız?

0 Cevap