Interchanging data with zend (multidimensional arrays)?

As your question quite long I will split my answer in few parts.

As your question quite long I will split my answer in few parts. PHP4Delphi component acts as SAPI module. The ISAPI SAPI module was used as a prototype for it What version of PHP4Delphi are you using?

In my copy the call to tsrm_shutdown(); is located on line 1509, not 1497 I would propose to read the array in the following way: procedure TForm1. ExecuteGetArray(Sender: TObject; Parameters: TFunctionParams; var ReturnValue: Variant; ZendVar: TZendVariable; TSRMLS_DC: Pointer); var ht : PHashTable; data: ^ppzval; cnt : integer; variable : pzval; tmp : ^ppzval; begin ht := GetSymbolsTable; if Assigned(ht) then begin new(data); if zend_hash_find(ht, 'ar', 3, data) = SUCCESS then begin variable := data^^; if variable^. _type = IS_ARRAY then begin SetLength(ar, zend_hash_num_elements(variable^.

Value.Ht)); for cnt := 0 to zend_hash_num_elements(variable^.value. Ht) -1 do begin new(tmp); zend_hash_index_find(variable^.value. Ht, cnt, tmp); arcnt := tmp^^^.value.str.

Val; freemem(tmp); end; end; end; freemem(data); end; end; Some people reported about the problems with integer indexes for arrays. I would propose to change the index to string: procedure TPHPExtension1. PHPExtension1Functions1Execute(Sender: TObject; Parameters: TFunctionParams; var ReturnValue: Variant; ZendVar : TZendVariable; TSRMLS_DC: Pointer); var pval : pzval; cnt : integer; months : pzval; smonths : pzval; begin pval := ZendVar.

AsZendVariable; if _array_init(pval, nil, 0) = FAILURE then begin php_error_docref(nil , TSRMLS_DC, E_ERROR, 'Unable to initialize array'); ZVAL_FALSE(pval); Exit; end; months := MAKE_STD_ZVAL; smonths := MAKE_STD_ZVAL; _array_init(months, nil, 0); _array_init(smonths, nil, 0); for cnt := 1 to 12 do begin add_next_index_string(months, PChar(LongMonthNamescnt), 1); add_next_index_string(smonths, PChar(ShortMonthNamescnt), 1); end; add_assoc_zval_ex(pval, 'months', strlen('months') + 1, months); add_assoc_zval_ex(pval, 'abbrevmonths', strlen('abbrevmonths') + 1, smonths); end; The error in tsrm_shutdown is usually related to the memory management and Delphi strings. Php5ts. Dll has built-in memory manager and it works independent from the Delphi memory manager.

When the string reference is equal to zero from the Delphi point of view it can be deallocated, but at the same time it can be still in use by the PHP engine. If you populate your subarrays with strings make sure the strings are not collected by the Delphi memory manager. For example you can convert the strings to PAnsiChar before adding it to the array {$IFNDEF COMPILER_VC9} fnc^.

Internal_function. Function_name := strdup(method_name); {$ELSE} fnc^. Internal_function.

Function_name := DupStr(method_name); {$ENDIF}.

Perevoznyk, thanks for the answer and sorry for the delay before reacting - I'm really busy right now with other stuff... – ain Oct 1 at 20:01 The php4delphi. Pas is v 7.2 10/2009 but I have changed it (both added functionality and just reformated to be more readable to me). I do use both str and int indices with arrays when I send data back to PHP.

Usually I have "root level" indices as ints and then the "leaf arrays" have string indices... what problems have there been with int indices? Would it be OK to use StrToInt() at Delphi side for indices or must it be "pure string" to be on the safe side? When sending string to PHP I use the version of API calls which take "dublicate" parameter, so I should be OK in that respect.

– ain Oct 1 at 20:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions