Guest User

Untitled

a guest
Jan 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function parse_lines($p_CSVLines,$c_Names,$separator)
  2. {
  3. $content = FALSE;
  4. if( !is_array($content) ) { // the first line contains fields numbers
  5. $this->fields = $c_Names;
  6. $content = array();
  7. }
  8.  
  9. foreach($p_CSVLines as $line_num => $line){
  10. if($line != ''){ // skip empty lines
  11. $elements = split($separator, $line);
  12. $item = array();
  13. foreach($this->fields as $id => $field){
  14. if( isset($elements[$id]) ){
  15. $field = trim($field,""");
  16. $item[$field] = trim($elements[$id],""");
  17. }
  18. }
  19. $content[] = $item;
  20. }
  21. }
  22. return $content;
  23. }
Add Comment
Please, Sign In to add comment