Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.


I am porting some PHP application to Zephir. Now application using a lot of PHP userland functions, like array_diff and array_merge functions, but I see that there are no optimizers for those PHP functions. So what is best way to do them? Possible to copy/paste C code from PHP source for those functions and make optimizers for them, or is it enought to make optimizers just calling fast PHP functions in C sources?

edited Jun '16

Ok I see for array_merge function. But what about array_diff? Am I missing something? Or any other function that is not covered with already written optimizers?

Creating optimizers that call the internal functions would have less overhead than the ones that are called in the php userland.

edited Jun '16

So if possible something like this:

void zephir_fast_array_flip(zval *return_value, zval **array TSRMLS_DC) {

    int init_size;

    if (Z_TYPE_PP(array) != IS_ARRAY) {
        zend_error(E_WARNING, "Argument is not an array");

    init_size = zend_hash_num_elements(Z_ARRVAL_PP(array));

    array_init_size(return_value, init_size);

    php_array_flip(Z_ARRVAL_P(return_value), Z_ARRVAL_PP(array), 0 TSRMLS_CC);

Tried but give me the error:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/' - /usr/lib/php5/20131226/ undefined symbol: php_array_flip in Unknown on line 0


So need just: array_flip?