From: Joshua Kehn on
I'm working on creating a compiled extension for some code I've written. Mostly it's manipulating a very large multi-demensional array of values. This is some pseudo code for the array.

// Imagine this but much much bigger
$big_ass_array = array('5' => array('0' => 4, '3' => 6, '8' => 7), '10' => array('4' => 3, '5' => 10'));

Currently I'm traversing this with

foreach($array as $key1 => $value)
{
foreach($value as $key2 => $value)
{
// Use $key1, $key2, and $value here
}
}

My question is how does this translate into the C code I will have to write?

If anyone has a decent extension building tutorial that would be great too.

Regards,

-Josh
____________________________________
Joshua Kehn | Josh.Kehn(a)gmail.com
http://joshuakehn.com

From: Jim Lucas on
Joshua Kehn wrote:
> I'm working on creating a compiled extension for some code I've written. Mostly it's manipulating a very large multi-demensional array of values. This is some pseudo code for the array.
>
> // Imagine this but much much bigger
> $big_ass_array = array('5' => array('0' => 4, '3' => 6, '8' => 7), '10' => array('4' => 3, '5' => 10'));
>
> Currently I'm traversing this with
>
> foreach($array as $key1 => $value)
> {
> foreach($value as $key2 => $value)
> {

Well, I hope you are not using it this way.

The above will overwrite your $value variable set by the first foreach

Maybe you had a cut/paste error with the $value1 $value2 portion...

> // Use $key1, $key2, and $value here
> }
> }
>
> My question is how does this translate into the C code I will have to write?

My suggestion would be to download the source code and find a comparable
array function and see how they do it.

>
> If anyone has a decent extension building tutorial that would be great too.

First google result for "php extension tutorial"

http://devzone.zend.com/article/1021
http://www.talkphp.com/vbarticles.php?do=article&articleid=49&title=creating-custom-php-extensions
http://www.php.net/~wez/extending-php.pdf

Just to list a few...

Jim

>
> Regards,
>
> -Josh
> ____________________________________
> Joshua Kehn | Josh.Kehn(a)gmail.com
> http://joshuakehn.com
>
>

From: Joshua Kehn on
Jim-

Yes, that was a typo. The issues was I didn't cut / paste and instead retyped it. Should be

foreach($array as $key1 => $list)
{
foreach($list as $key2 => $value)

I will check those links out, I had the first one not the second.

Regards,

-Josh
____________________________________
Joshua Kehn | Josh.Kehn(a)gmail.com
http://joshuakehn.com

On Sep 5, 2010, at 12:32 AM, Jim Lucas wrote:

> Joshua Kehn wrote:
>> I'm working on creating a compiled extension for some code I've written. Mostly it's manipulating a very large multi-demensional array of values. This is some pseudo code for the array.
>> // Imagine this but much much bigger
>> $big_ass_array = array('5' => array('0' => 4, '3' => 6, '8' => 7), '10' => array('4' => 3, '5' => 10')); Currently I'm traversing this with
>> foreach($array as $key1 => $value)
>> {
>> foreach($value as $key2 => $value)
>> {
>
> Well, I hope you are not using it this way.
>
> The above will overwrite your $value variable set by the first foreach
>
> Maybe you had a cut/paste error with the $value1 $value2 portion...
>
>> // Use $key1, $key2, and $value here
>> }
>> }
>> My question is how does this translate into the C code I will have to write?
>
> My suggestion would be to download the source code and find a comparable array function and see how they do it.
>
>> If anyone has a decent extension building tutorial that would be great too.
>
> First google result for "php extension tutorial"
>
> http://devzone.zend.com/article/1021
> http://www.talkphp.com/vbarticles.php?do=article&articleid=49&title=creating-custom-php-extensions
> http://www.php.net/~wez/extending-php.pdf
>
> Just to list a few...
>
> Jim
>
>> Regards,
>> -Josh
>> ____________________________________
>> Joshua Kehn | Josh.Kehn(a)gmail.com
>> http://joshuakehn.com
>