<?php

$input = "'54\",\"34',34,\"ab,ac\",10,20";
echo "<pre>$input\n\n";var_dump(my_parser($input)); echo "</pre>\n\n"; 
$input = "ab$,wdf;tt5,4h56;73t2";
echo "<pre>$input\n\n";var_dump(my_parser($input)); echo "</pre>\n\n"; 
$input = "'54\",\"'6'34',34,,\"ab,ac\",10,20";
echo "<pre>$input\n\n";var_dump(my_parser($input)); echo "</pre>\n\n"; 

function my_parser($input)
{
	$delimeters = [',', ';'];
	$quotes = ['"', '\''];
	$currentQuote = null;
	$currentArg = '';
	$args = [];
	
	$len = strlen($input);
	for ($i=0; $i<$len; $i++) {
		$currentSymbol = $input[$i];
		
		if (!empty($currentQuote)) { // we're in quotes
			if ($currentQuote === $currentSymbol) { // and quote matched
				$currentQuote = null; // so quote closed!
			} else { // quoted quote, lol
				$currentArg .= $currentSymbol; // let it go, it's string
			}
		} else { // not in quotes
			if (in_array($currentSymbol, $quotes)) { // check if symbol is quote
				$currentQuote = $currentSymbol; // and remember this quote
			} elseif (in_array($currentSymbol, $delimeters)) { // check for delimeter
				if (strlen($currentArg)) {
					$args[] = $currentArg; // it's end of valid argument, yeah!
					$currentArg = '';
				}
			} else { // simple symbol, pass it
				$currentArg .= $currentSymbol; // let it go, it's string
			}
		}
	}
	if (strlen($currentArg)) {
		$args[] = $currentArg;
	}
	return $args;
}
