title: how to convert zval to vector for php extension?
body: <p>i'm writing a php extension for my c++ library which is defined something like this:</p>
  
  <pre><code>bool getPids(map&lt;string,string&gt; pidsMap, vector&lt;string&gt; ids);
  </code></pre>
  
  <p>now, i'm writing a php wrapper for above function like this.</p>
  
  <pre><code>ZEND_METHOD(myFInfo, get_pids)
  {
      zval *idsArray;
  
      if (zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "a",
                                  &amp;idsArray ) == FAILURE )
      {
          RETURN_NULL();
      }
  }
  </code></pre>
  
  <p>now i want to call getPids(), but i don't know the proper way to pass idsArray as vector into the c++ function.</p>
  
  <p>after some search on web, i found an example where zval array is iterated to read each values, and i thought maybe i can use this to create a vector.</p>
  
  <pre><code>PHP_FUNCTION(hello_array_strings)
  {
      zval *arr, **data;
      HashTable *arr_hash;
      HashPosition pointer;
      int array_count;
      if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &amp;arr) == FAILURE) {
          RETURN_NULL();
      }
  
  arr_hash = Z_ARRVAL_P(arr);
  array_count = zend_hash_num_elements(arr_hash);
  
  php_printf("The array passed contains %d elements", array_count);
  
  for(zend_hash_internal_pointer_reset_ex(arr_hash, &amp;pointer); zend_hash_get_current_data_ex(arr_hash, (void**) &amp;data, &amp;pointer) == SUCCESS; 
  
  zend_hash_move_forward_ex(arr_hash, &amp;pointer)) {
  
              if (Z_TYPE_PP(data) == IS_STRING) {
                  PHPWRITE(Z_STRVAL_PP(data), Z_STRLEN_PP(data));
                  php_printf("
      ");
              }
          }
          RETURN_TRUE;
      }
  </code></pre>
  
  <p>but is this the best approach? or is there a better way to do this?</p>
  
  <p>thanks!</p>