Note Submitter: yuwas at ht dot cx
----
Since the function explode($delimiter,$input) is available for older versions, I propose this simpler two-functions solution:
<?php
function escape_explode($delimiter,$input,$escape='\\'){
$result =array();
foreach(explode(&delimiter,$input) as $item){
if(($result == array()) or ($result[-1] == '') or !($result[-1][-1] == '\\')){
$result .= $item;
}else{
$result[-1] .= $item;
};
};
return($result);
};
function str_getcsv($input, $delimiter=',', $enclosure='"', $escape='\\'){
$result = escape_explode($delimiter,$input,$escape);
for($i=0,$item=$result[0];$i<count($result);$i++,$item=$result[$i]){
$enclosed = escape_explode($enclosure,$item,$escape);
if(1 < count($enclosed)){
$result[$i] = $enclosed[($result[$i][0] == $enclosure)? 0: 1];
}else{
$result[$i] = $enclosed[0];
};
};
return($result);
};
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.