fork download
  1. <?php
  2. function comb( $strings) {
  3. $aKeys = str_getcsv( $strings[0]);
  4. $aVals = str_getcsv( $strings[1]);
  5. if( is_null( $aKeys) || is_null( $aVals) || ( count( $aKeys) != count( $aVals))) {
  6. return NULL;
  7. }
  8.  
  9. return array_combine( $aKeys, $aVals);
  10. }
  11.  
  12.  
  13. $strings = array(
  14. 0 => '"Datasheets","Image","Digi-Key Part Number","Manufacturer Part Number","Manufacturer","Description","Quantity Available","Factory Stock","Unit Price (USD)","@ qty","Minimum Quantity","Series","Accessory Type","Material","Color","For Use With/Related Products"',
  15. 1 => '"http://w...content-available-to-author-only...s.com/eng/content/download/3165/37817/version/2/file/bf-1861-000.pdf","http://m...content-available-to-author-only...y.com/Photos/Knowles%20Acoustics%20Photos/BF-1861-000.jpg","423-1158-ND","BF-1861-000","Knowles","ACOUSTIC DAMPER 1500 OHMS",1067,0,"1.67000",0,1,"BF","Damper","Metal Ferrule Housing","Green","Hearing Aids"',
  16. );
  17.  
  18. $result = comb( $strings);
  19. print_r( $result);
  20.  
  21.  
Success #stdin #stdout 0.02s 20600KB
stdin
Standard input is empty
stdout
Array
(
    [Datasheets] => http://w...content-available-to-author-only...s.com/eng/content/download/3165/37817/version/2/file/bf-1861-000.pdf
    [Image] => http://m...content-available-to-author-only...y.com/Photos/Knowles%20Acoustics%20Photos/BF-1861-000.jpg
    [Digi-Key Part Number] => 423-1158-ND
    [Manufacturer Part Number] => BF-1861-000
    [Manufacturer] => Knowles
    [Description] => ACOUSTIC DAMPER 1500 OHMS
    [Quantity Available] => 1067
    [Factory Stock] => 0
    [Unit Price (USD)] => 1.67000
    [@ qty] => 0
    [Minimum Quantity] => 1
    [Series] => BF
    [Accessory Type] => Damper
    [Material] => Metal Ferrule Housing
    [Color] => Green
    [For Use With/Related Products] => Hearing Aids
)