Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51154 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13571 invoked from network); 31 Dec 2010 14:08:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2010 14:08:37 -0000 Authentication-Results: pb1.pair.com header.from=kalle.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=kalle.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kalle.php@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:46271] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 48/F1-01063-4E3ED1D4 for ; Fri, 31 Dec 2010 09:08:37 -0500 Received: by vws11 with SMTP id 11so4601643vws.29 for ; Fri, 31 Dec 2010 06:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=ifJvAG+d//8PcBlVtVt00RmYV2Q4JAMYUsU/Q0yMqqM=; b=MeZom2rc/kjmEYi9kQcawD5eo7G7MOLUZUgK3to1GITfqq4arnUJkg9I9b+/ypWxEu kMHEgbLeEmDMiWzl8b3wYEWgimNstk2MXYurn8CqL4Mpx+J+qBw0Ec1NKNRpFsMNN7kt PgOtOUQRJLFuuzSTA2Q/5ZvvFRSzNbxTLH3xk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=E18l31tlyEJNRx0Y6+boSt1rVNbH4RlIoNfheRUewsJzz8IY83GgY7vB3P8VnP1XVt siWgSGB1rlSeCSQAPshT6cgG/PIVwad3y+ja7w0zouwM2OsmD1oqWnooG9hZ5lGn6siz 25Ss9hUCnLQfAzbXLmI//oamPPdpgrXq+1Lhw= MIME-Version: 1.0 Received: by 10.220.188.133 with SMTP id da5mr5319691vcb.175.1293804514033; Fri, 31 Dec 2010 06:08:34 -0800 (PST) Sender: kalle.php@gmail.com Received: by 10.220.185.69 with HTTP; Fri, 31 Dec 2010 06:08:33 -0800 (PST) In-Reply-To: References: Date: Fri, 31 Dec 2010 15:08:33 +0100 X-Google-Sender-Auth: V66qWVma6R6khccJb-BfbkXgMls Message-ID: To: RQuadling@googlemail.com Cc: PHP internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Working with arrays. From: kalle@php.net (Kalle Sommer Nielsen) Hi Richard 2010/12/31 Richard Quadling : > Hi. > > What macros exist regarding processing arrays in PHP (core not userland)? Zend hash, see Zend/zend_hash.c for its API. > I want to pass ... > > array('value1', 'value2', 'value3') You would do something like: PHP_FUNCTION(test) { zval *array; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) { return; } /* Z_ARRVAL_P(array) is a HashTable* ptr */ } > > to a function and in the function have it converted to > > 'value1\0value2\0value3\0\0'. > > Conventionally, I'd need to iterate the array to get the lengths of > all the elements, add the number of elements to this value and then 1 > more for the trailing \0. The move_forward, get_current etc. hash functions can be used to iterate, see zend_hash.h: http://lxr.php.net/opengrok/xref/PHP_TRUNK/Zend/zend_hash.h#194 -- regards, Kalle Sommer Nielsen kalle@php.net