fork(1) download
  1. <?php
  2. function comb( $strings) {
  3. $aKeys = json_decode( '[' . $strings[0] . ']');
  4. $aVals = json_decode( '[' . $strings[1] . ']');
  5.  
  6. if( is_null( $aKeys) || is_null( $aVals) || ( count( $aKeys) != count( $aVals))) {
  7. return NULL;
  8. }
  9.  
  10. return array_combine( $aKeys, $aVals);
  11. }
  12.  
  13.  
  14. $strings = array(
  15. 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"',
  16. 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"',
  17. );
  18.  
  19. $result = comb( $strings);
  20. print_r( $result);
  21.  
  22.  
Success #stdin #stdout 0.03s 20568KB
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
)