using Php;

namespace PhpNative {
    public Gee.ArrayList<string> explode (string separator, string value) {
        var result = new Gee.ArrayList<string> ();
        foreach (string part in value.split (separator)) {
            result.add (part);
        }
        return result;
    }

    public Gee.ArrayList<string> explode_static (string separator, string value, string php_file, int php_line) throws Error {
        return explode (separator, value);
    }

    public zval explode_zval (zval separator, zval value, string php_file, int php_line) throws Error {
        zval result = zval.array ();
        foreach (string part in explode_static (zval_to_string (separator), zval_to_string (value), php_file, php_line)) {
            array_append (result, zval.string_value (part));
        }
        return result;
    }
}
