Re: Function parameters and arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18 Sep 2008, at 16:29, Frank Stanovcak wrote:
I am trying to pass a multi dimmed array as a variable parameter to a custom function to build a query for me. Here is the basic code and what I am
getting.

$WhereList[0][0] = 'OESalesOrder.OrderNo';
$WhereList[0][1] = '=';
$WhereList[0][2] = '2272';
$SQLString = SQLCall('OESalesOrder',$FieldList,$WhereList);

I then use a foreach in the function to process it.

$i = 0;
  foreach(func_get_arg(2) as $WhereArray) {

This foreach will give you each array at the first level into $WhereArray...

   echo $WhereArray[0][0];

So there is no need for the first [0] here.

   if($i == 0) {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i] [1] . ' ' .
$WhereArray[$i][2];
    $i += 1;
   } else {
$SQLStmt .= ' ' . $WhereArray[$i][0] . ' ' . $WhereArray[$i] [1] . ' ' .
$WhereArray[$i][2] . ' ' . $WhereArray[$i][3];
    $i += 1;
   };
  };

And $i is not needed at all.

What I get when it processes is the first three letters of [0][0]
[0][0] = O
[0][1] = E
[0][2] = S

Did I do something wrong, or is this not possible? I have done an array
processing this way before, but not multidimmed.

Suggest you read this: http://php.net/foreach

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux