Re: [PHP] PHP array unions

2012-09-14 Thread Matijn Woudt
Op 14 sep. 2012 07:51 schreef Adam Richardson simples...@gmail.com het
volgende:

 On Wed, Sep 12, 2012 at 2:37 PM, Sebastian Krebs krebs@gmail.com
wrote:
  Hi,
 
  In PHP the array is in fact a hash map, but especially it is _used_ for
  nearly everything map-, set-, ...-like thing. So in short: The is no
  operator or built-in function, that merges two arrays _and_ treat them
as
  set (instead of the hashmap, what they are). Your solution is the way
to go.

 Sure, I know about the underlying implementation. I was just hopeful
 because several of the array functions handle the maps differently
 depending on whether the keys are numeric or string or both.

 If I wanted to get cute, I could store the value in the key (e.g.,
 array('value 1' = 0, 'value 2' = 0, ...)), and that allows me to use
 the '+' operator. In spite of the nice performance benefits of this
 approach (leveraging the hashes benefits), the code that utilizes the
 arrays becomes quite clunky.

 Thanks,

 Adam


It doesn't need to be clunky.. just use array_flip and you've got the old
array again..

-Matijn


Re: [PHP] PHP array unions

2012-09-14 Thread Adam Richardson
On Fri, Sep 14, 2012 at 2:30 AM, Matijn Woudt tijn...@gmail.com wrote:

 It doesn't need to be clunky.. just use array_flip and you've got the old
 array again..


Well, array_flip has it's own potential issues (duplicate values are
lost, so my example of using zeros would not work.) I suppose I could
duplicate the keys as the values (e.g., array('value 1' = 'value 1',
'value 2' = 'value 2', ...).) Then, the keys would  allow me to
utilize the nice properties of hash maps whilst maintaining the
ability to work with the values as one normally does in typical array
functions.

Ex:

$a1 = array('apples' = 'apples', 'oranges' = 'oranges', 'pears' = 'pears');
$a2 = array('oranges' = 'oranges', 'kiwi' = 'kiwi');
// can use the union operator without any additional calls and the
performance is stellar
$a3 = $a1 + $a2
// can use the values of the array using the convention that the value
is what you expect to handle/manipulate
foreach ($a3 as $val) {
  echo $val
}

Here, the clunkiness is the redundancy in the array, but, as Claude
Shannon has demonstrated, redundancy isn't all bad :)

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

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



Re: [PHP] PHP array unions

2012-09-13 Thread Adam Richardson
On Wed, Sep 12, 2012 at 2:37 PM, Sebastian Krebs krebs@gmail.com wrote:
 Hi,

 In PHP the array is in fact a hash map, but especially it is _used_ for
 nearly everything map-, set-, ...-like thing. So in short: The is no
 operator or built-in function, that merges two arrays _and_ treat them as
 set (instead of the hashmap, what they are). Your solution is the way to go.

Sure, I know about the underlying implementation. I was just hopeful
because several of the array functions handle the maps differently
depending on whether the keys are numeric or string or both.

If I wanted to get cute, I could store the value in the key (e.g.,
array('value 1' = 0, 'value 2' = 0, ...)), and that allows me to use
the '+' operator. In spite of the nice performance benefits of this
approach (leveraging the hashes benefits), the code that utilizes the
arrays becomes quite clunky.

Thanks,

Adam

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



Re: [PHP] PHP array unions

2012-09-12 Thread Sebastian Krebs

Hi,

In PHP the array is in fact a hash map, but especially it is _used_ for 
nearly everything map-, set-, ...-like thing. So in short: The is no 
operator or built-in function, that merges two arrays _and_ treat them 
as set (instead of the hashmap, what they are). Your solution is the way 
to go.


Regards,
Sebastian

Am 12.09.2012 17:10, schrieb Adam Richardson:

Hi!

So, PHP has the '+' array operator, which forms the union of arrays,
but it does so by key. What I'm looking for is a function that forms
the union of arrays based on value. Currently, I use code like the
following:

array_unique(array_merge($array1, $array2, $array3));

This is useful to me because I tend to program using functional
programming principles. Just want to make sure I'm not missing a core
function that already does this. If there's not a core function, I
might just build an array_union extension because the functionality is
so common in my codebases.

Thanks,

Adam




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



Re: [PHP] php array in different OS

2010-07-27 Thread jose javier parra sanchez
you are probably getting a memory limit error, check your php.ini

2010/7/21 fyang fy...@ipp.ac.cn:
 Dear all,
   I have a simple test code in different OS ,but it give me a different
 result.
   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and
 count:5.

  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it can
 not display count value.
  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

 good luck,

 Yang Fei
 2010-7-20

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



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



RE: [PHP] php array in different OS

2010-07-21 Thread Bob McConnell
From: fyang

 I have a simple test code in different OS ,but it give me a
different 
 result.
 the code as follows:
?php
 $n= 5;
 for($i=0;$i$n;$i++)
 {
  $data[]=array(,$i,$i/1000);
  echo $i,  ,$data[$i][1],br;
 }
 echo count:,count($data);
?
OS1:  Red Hat Enterprise Linux Server release 5.1
  Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result:  the result is correct,it can display 5 data and 
 count:5.
 
OS2: CentOS release 5.4
 Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and
it 
 can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.

Did you really have to post the same message eight times?

CentOS is Red Hat minus the proprietary elements, so you actually have
two releases of the same OS here. The bigger question is what version of
PHP are you running on each of them and how are they configured?

Bob McConnell

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



Re: [PHP] php array in different OS

2010-07-21 Thread fyang
Dear Bob McConnell,
   Thank you for your reply.
   I really post the same message eight times because of the first e-mail 
authentication.please remove the extra e-mail in your free time.
   There are two servers ,the first installation of 32-bit linux(RHEL),the 
second installlation 64-bit linux(CENTOS).
   PHP version on 32-bit linux(RHEL):5.2.7
   PHP version on 64-bit linux(CENTOS):5.2.13
  I found this problem,because the software transplantation.In the 64-bit 
systems,the array seems to always have limited capacity. I'm not sure that is 
php version problem or need other configurations.
  Please give further guidance, thank you very much!


best wishs,

Yang Fei
2010-7-22








发件人: Bob McConnell 
发送时间: 2010-07-21  20:06:36 
收件人: fyang; php-general@lists.php.net 
抄送: 
主题: RE: [PHP] php array in different OS 
 
From: fyang

 I have a simple test code in different OS ,but it give me a
different 
 result.
 the code as follows:
 ?php
 $n= 5;
 for($i=0;$i $n;$i++)
 {
  $data[]=array(,$i,$i/1000);
  echo $i,  ,$data[$i][1], br ;
 }
 echo count:,count($data);
? 
OS1:  Red Hat Enterprise Linux Server release 5.1
  Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
test result:  the result is correct,it can display 5 data and 
 count:5.
 
OS2: CentOS release 5.4
 Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
test result: the result is wrong,it can only display 31148 data and
it 
 can not display count value.
I'm not sure the result relate to array capacity in different OS.
Please give me some tips,thanks in advance.

Did you really have to post the same message eight times?

CentOS is Red Hat minus the proprietary elements, so you actually have
two releases of the same OS here. The bigger question is what version of
PHP are you running on each of them and how are they configured?

Bob McConnell


[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20 



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



[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20


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



[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20


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



[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20


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



[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20 



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



[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20 



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



[PHP] php array in different OS

2010-07-20 Thread Yang Fei
Dear all,
I have a simple test code in different OS ,but it give me a different 
result.
the code as follows:
   ?php
$n= 5;
for($i=0;$i$n;$i++)
{
 $data[]=array(,$i,$i/1000);
 echo $i,  ,$data[$i][1],br;
}
echo count:,count($data);
   ?
   OS1:  Red Hat Enterprise Linux Server release 5.1 
 Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
   test result:  the result is correct,it can display 5 data and 
count:5.

   OS2: CentOS release 5.4 
Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
   test result: the result is wrong,it can only display 31148 data and it can 
not display count value.
   I'm not sure the result relate to array capacity in different OS.
   Please give me some tips,thanks in advance. 

good luck,

Yang Fei
2010-7-20


[PHP] php array in different OS

2010-07-20 Thread fyang

Dear all,
   I have a simple test code in different OS ,but it give me a different 
result.

   the code as follows:
  ?php
   $n= 5;
   for($i=0;$i$n;$i++)
   {
$data[]=array(,$i,$i/1000);
echo $i,  ,$data[$i][1],br;
   }
   echo count:,count($data);
  ?
  OS1:  Red Hat Enterprise Linux Server release 5.1
Linux 2.6.18-53.el5xen i686 i686 i386 GNU/Linux
  test result:  the result is correct,it can display 5 data and 
count:5.


  OS2: CentOS release 5.4
   Linux 2.6.18-164.el5 x86_64 x86_64 x86_64 GNU/Linux
  test result: the result is wrong,it can only display 31148 data and it 
can not display count value.

  I'm not sure the result relate to array capacity in different OS.
  Please give me some tips,thanks in advance.

good luck,

Yang Fei
2010-7-20 



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



[PHP] PHP: array with null shows different with print_r and var_dump

2008-04-02 Thread Sanjay Mantoor
Hello,

I am new to PHP and PHP community.

Following program outputs different values with print_r and var_dump.

$array = array(null, NULL);

print_r($array); prints values like below
Array
(
[0] =
[1] =
)

where as var_dump($array) prints values like below
array(2) {
  [0]=
  NULL// Does this convert to null to NULL?
  [1]=
  NULL
}

Can you tell me why the above difference?


-- 
Thanks,
Sanjay Mantoor


Re: [PHP] PHP: array with null shows different with print_r and var_dump

2008-04-02 Thread Casey
On Tue, Apr 1, 2008 at 11:49 PM, Sanjay Mantoor
[EMAIL PROTECTED] wrote:
 Hello,

  I am new to PHP and PHP community.

  Following program outputs different values with print_r and var_dump.

  $array = array(null, NULL);

  print_r($array); prints values like below
  Array
  (
 [0] =
 [1] =
  )

print_r converts null, which is a variable type, like integer, string,
float, etc, into an empty string.
  where as var_dump($array) prints values like below
  array(2) {
   [0]=
   NULL// Does this convert to null to NULL?
null is case-insensitive, so it doesn't matter how you type it.
   [1]=
   NULL
  }
var_dump converts null into the string NULL.

  Can you tell me why the above difference?



-- 
-Casey

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



Re: [PHP] PHP: array with null shows different with print_r and var_dump

2008-04-02 Thread Robert Cummings

On Wed, 2008-04-02 at 12:19 +0530, Sanjay Mantoor wrote:
 Hello,
 
 I am new to PHP and PHP community.
 
 Following program outputs different values with print_r and var_dump.
 
 $array = array(null, NULL);
 
 print_r($array); prints values like below
 Array
 (
 [0] =
 [1] =
 )
 
 where as var_dump($array) prints values like below
 array(2) {
   [0]=
   NULL// Does this convert to null to NULL?
   [1]=
   NULL
 }
 
 Can you tell me why the above difference?

NULL and null are the same thing. If I'm correct var_dump() was created
to solve the problem of not knowing what the datatypes are when using
print_r().

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP array entries max limit

2008-01-17 Thread Per Jessen
Prabath Kumarasinghe wrote:

 Hi All
 
 I would like to know how many entries does PHP associative array can
 handle.

Why don't you just test it? 
for( $i=0; ; $i++ )
{
$kk[$i]=1;
}

Attempt#1 - 13 keys, stopped due to memory limit *M.
Attempt#2 - 838 keys, memlimit 512M.
Attempt#3 - 2958 keys, memlimit 2G.


/Per Jessen, Zürich

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



Re: [PHP] PHP array entries max limit

2008-01-17 Thread Richard Lynch
On Wed, January 16, 2008 11:02 pm, Prabath Kumarasinghe wrote:
 I would like to know how many entries does PHP associative array can
 handle.

As far as I know, the answer is:

How much RAM do you have?

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



[PHP] PHP array entries max limit

2008-01-16 Thread Prabath Kumarasinghe
Hi All

I would like to know how many entries does PHP associative array can handle.

Cheers

Prabath


[PHP] php array and java fold out menu

2005-07-29 Thread Gregory Machin
Hi .
Please could you advise.
I'm insearch of a java fold out menu that looks good, and can acept an
array containg the links and link names etc from a php array ... i
havent worked in java script yet so please help :-)...

Many thanks 

-- 
Gregory Machin
[EMAIL PROTECTED]
[EMAIL PROTECTED]
www.linuxpro.co.za
Web Hosting Solutions
Scalable Linux Solutions 
www.iberry.info (support and admin)
www.goeducation (support and admin)
+27 72 524 8096

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



[PHP] PHP Array question

2005-02-15 Thread R. Van Tassel
I have an array with image names like:

 

$arrayone = array(1.jpg, 2.jpg);

$arraytwo = array(a.jpg, b.jpg);

 

 

Then I have a variable for each to count the number of elements:

 

$arrayoneElements = count($arrayone);

$arraytwoElements = count($arraytwo);

 

 

I'm using the element variables to control the loop to display all the array
elements.

 

This is it:

 

for($ctr=1; $ctr  $elemcount; $ctr++){

   if($ctr%5){

  echo td width=\20%\a
href=\javascript:popup_pic('.$gallerypath./$arr[$ctr]')\img
src=\.$gallerypath.thumbs/$arr[$ctr]\ alt=\no image\ //a/td;

   }else{

  echo td width=\20%\a
href=\javascript:popup_pic('.$gallerypath./$arr[$ctr]')\img
src=\.$gallerypath.thumbs/$arr[$ctr]\ alt=\no image\
//a/td/tr\ntr;

   }

}

 

 

What I want to do is to only show 20 pictures at a time with a Next link
and a Previous link. For the first 20 only the Next link would show and
whenever the last set would show only the Previous link would. Every other
time both would show.

 

Can someone point me in the right direction on how to count through the
elements until the end and back to display them? I just can't figure it out.

 

Thanks,

-Roy

 



Re: [PHP] PHP Array question

2005-02-15 Thread Matt M.
 What I want to do is to only show 20 pictures at a time with a Next link
 and a Previous link. For the first 20 only the Next link would show and
 whenever the last set would show only the Previous link would. Every other
 time both would show.
 
 Can someone point me in the right direction on how to count through the
 elements until the end and back to display them? I just can't figure it out.


sounds like you just might need some paging functions

http://pear.php.net/package/Pager
http://pear.php.net/manual/en/package.html.pager.php

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



[PHP] php array question

2004-11-01 Thread Victor C.
Hi,
I have a line of php that I don't really understand.

foreach($this-orders as $OrderID = $value) {
echo $OrderID.BR;
$OrderObject =$this-orders[$OrderID=$value];
echo $OrderObject-OrderID.--all the sameBR;
}

I know that $this-orders is an array of order objects.

the result i get from this is:

line1. 388--OrderID.
line2. 389--all the same
line3. 389--OrderID.
line4. 389--all the same

I'm really confused about why line 1 and line 3 have different OrderID, but
line 2 and 4 have the same... I've been trying to fix this bug for 3 hrs
with no luck.
Any help would be really appreciated..

Thanks a lot

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



RE: [PHP] php array question

2004-11-01 Thread Zareef Ahmed



-Original Message-
From: Victor C. [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 02, 2004 3:06 AM
To: [EMAIL PROTECTED]
Subject: [PHP] php array question


Hi,
I have a line of php that I don't really understand.

foreach($this-orders as $OrderID = $value) {
echo $OrderID.BR;
I think Problem is with this line (I am surprised to see it does not
throw a parsing error. As it should !)
$OrderObject =$this-orders[$OrderID=$value];

If $this-orders is an array of order objects then
Following line should be  sufficient 
$OrderObject =$this-orders[$OrderID];
  Or
$OrderObject =$value;

Zareef ahmed
echo $OrderObject-OrderID.--all the sameBR;
}

I know that $this-orders is an array of order objects.

the result i get from this is:

line1. 388--OrderID.
line2. 389--all the same
line3. 389--OrderID.
line4. 389--all the same

I'm really confused about why line 1 and line 3 have different OrderID,
but line 2 and 4 have the same... I've been trying to fix this bug for
3 hrs with no luck. Any help would be really appreciated..

Thanks a lot


--
Zareef Ahmed :: A PHP develoepr in Delhi ( India )
Homepage :: http://www.zasaifi.com

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



[PHP] php array

2002-03-12 Thread Rodrigo Peres

Hi list,

I think this could be an idiot question but I couldn't find an answer.
I have 4 input text in a html, and I'd like to store them as a list, so I've
named it Name[]. OK, php understand it as an array, but how can I make an
validation code with javascript to know if the user didn't typed in this
fields??? I couldn't do javascript recognize my name[] field


Thank's in advance

Rodrigo
-- 



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




RE: [PHP] php array

2002-03-12 Thread Demitrious S. Kelly

Something like this:
?php
$valid=1;
foreach ( $name as $value ) {
if ( $value == '' || ! isset($value) ) {
$valid=0;
}
}
if ( $valid == 1 ) {
do_stuff();
} else {
give_error();
}   
?
-Original Message-
From: Rodrigo Peres [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 12, 2002 10:11 AM
To: PHP
Subject: [PHP] php array

Hi list,

I think this could be an idiot question but I couldn't find an answer.
I have 4 input text in a html, and I'd like to store them as a list, so
I've
named it Name[]. OK, php understand it as an array, but how can I make
an
validation code with javascript to know if the user didn't typed in this
fields??? I couldn't do javascript recognize my name[] field


Thank's in advance

Rodrigo
-- 



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



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




Re: [PHP] php array

2002-03-12 Thread Jim Lucas [php]

you could referance the element id of the form

something like

if(window.document.form.element[1].value = )
{
do_something();
}

not sure of the exact js construct, but you get my idea.

Jim Lucas
www.bend.com
- Original Message -
From: Rodrigo Peres [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Tuesday, March 12, 2002 10:10 AM
Subject: [PHP] php array


 Hi list,

 I think this could be an idiot question but I couldn't find an answer.
 I have 4 input text in a html, and I'd like to store them as a list, so
I've
 named it Name[]. OK, php understand it as an array, but how can I make an
 validation code with javascript to know if the user didn't typed in this
 fields??? I couldn't do javascript recognize my name[] field


 Thank's in advance

 Rodrigo
 --



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




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




Re: [PHP] PHP array or SQL problem

2002-01-15 Thread Dean Householder

Thanks so much!!  You guys rock!
Dean


- Original Message -
From: Dean Householder [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, January 15, 2002 12:34 AM
Subject: [PHP] PHP array or SQL problem


I've got a database with lname (lastname), fname (firstname), and nickname.

What I want to do is search by either first name or last name.  Either way,
I display the nickname instead of the firstname if it exists.  I have no
problems on the last name, but when I sort by firstname, the people with
nicknames that are very different come up at the place where their first
name (not the displayed name) is.

For example:

Adam Smith
Joe Schmoe
Bill Somebody

When Bill Somebody is really William Somebody in the database, his nickname
is bill and that's what's displayed but he 'bill' shows up in 'williams'
spot.  Here is my SQL query:

select * from employees order by fname;

Should I create an array and sort it there or can I somehow query MySQL to
sort by nickname only if it exists and then by fname?

Dean



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] PHP array or SQL problem

2002-01-14 Thread Dean Householder

I've got a database with lname (lastname), fname (firstname), and nickname.

What I want to do is search by either first name or last name.  Either way, I display 
the nickname instead of the firstname if it exists.  I have no problems on the last 
name, but when I sort by firstname, the people with nicknames that are very different 
come up at the place where their first name (not the displayed name) is.

For example:

Adam Smith
Joe Schmoe
Bill Somebody

When Bill Somebody is really William Somebody in the database, his nickname is bill 
and that's what's displayed but he 'bill' shows up in 'williams' spot.  Here is my SQL 
query:

select * from employees order by fname;

Should I create an array and sort it there or can I somehow query MySQL to sort by 
nickname only if it exists and then by fname?

Dean



[PHP] Php Array

2001-11-16 Thread Wee Chua

Hi all,
How can I send the values inside the array into a function for calculation?

Thank you,
Calvin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Php Array

2001-11-16 Thread Boget, Chris

 How can I send the values inside the array into a function 
 for calculation?

function addValues( $arrayVar ) {
  $reteval = 0;

  foreach( $arrayVar as $element ) {
$retval += $element;

  }

  return $retval;

}

$myArray = array( 1, 2, 3, 4, 4 );

echo addValues( $myArray );

Chris



[PHP] PHP array information.

2001-07-09 Thread Chris Oxenreider


Hello:

My apologies if this has been covered before, or if i have missed it on
the php manual web pages.  I am looking for some information on how to do
a perl like array with a *sql call in PHP.


Here is what I want to do:

table:
  problem_class
_rid (tinyint)
description (mediumtext)

Sample data:
_riddescription
1   open
2   closed
3   testing
10  S
11  M
12  L
13  XL
20  Black
21  Red
22  Green
23  Blue


In perl this might be accomplished by doing this:
   (Note some pseudo code is used here.  Assume mysql as database but
could be others like Oracle.)

   $query  = SELECT _rid,description FROM problem_class;
   $q_pointer = sql_query($query);
   @problem_class = sql_associate_array_get($q_pointer);

   print select name=\status\\n;
   for ($i = 0; $i  10 ; ++$i) {
   if ( $problem_class[$i] ne ) {
   print option value=\$i\ $problem_class[$i]\n;
   }
   }
   print /select\n;

   print select name=\size\\n;
   for ($i = 10; $i  20 ; ++$i) {
   if ( $problem_class[$i] ne ) {
   print option value=\$i\ $problem_class[$i]\n;
   }
   }
   print /select\n;

   print select name=\color\\n;
   for ($i = 20; $i  30 ; ++$i) {
   if ( $problem_class[$i] ne ) {
   print option value=\$i\ $problem_class[$i]\n;
   }
   }
   print /select\n;


This produces something very close to this:

select name=status
option value=1 open
option value=2 closed
option value=3 testing
/select

select name=size
option value=10 S
option value=11 M
option value=12 L
option value=13 XL
/select

select name=color
option value=20 Black
option value=21 Red
option value=22 Green
option value=23 Blue
/select


If I could use something like this, it would allow me to produce different
'for' statements for each select drop down I wanted to create.  One table
to maintain, and change encase politics force me to change some of
definitions with out having to do a massive sql update.  This works as
long as the problem_class table is rather short (ie less than 1,000
records).

I know I am missing something 'obvious' in this.  Your help is
appreciated.  Thank you.




-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Chris Oxenreider | [EMAIL PROTECTED] | http://www.state.net/~oxenreid
 | MicroSoft Windows 2000: The De facto sub standard.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] PHP array information.

2001-07-09 Thread scott [gts]

i dont quite think i understand the question, but if you
want to fetch results as an array with mysql, do this:

$result = mysql_query( sql );
mysql_fetch_array($result);

 -Original Message-
 From: Chris Oxenreider [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 09, 2001 12:39 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] PHP array information.
 
 
 
 Hello:
 
 My apologies if this has been covered before, or if i have missed it on
 the php manual web pages.  I am looking for some information on how to do
 a perl like array with a *sql call in PHP.
 
 
 Here is what I want to do:
 
 table:
   problem_class
 _rid (tinyint)
 description (mediumtext)
 
 Sample data:
 _riddescription
 1   open
 2   closed
 3   testing
 10  S
 11  M
 12  L
 13  XL
 20  Black
 21  Red
 22  Green
 23  Blue
 
 
 In perl this might be accomplished by doing this:
(Note some pseudo code is used here.  Assume mysql as database but
 could be others like Oracle.)
 
$query  = SELECT _rid,description FROM problem_class;
$q_pointer = sql_query($query);
@problem_class = sql_associate_array_get($q_pointer);
 
print select name=\status\\n;
for ($i = 0; $i  10 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
 
print select name=\size\\n;
for ($i = 10; $i  20 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
 
print select name=\color\\n;
for ($i = 20; $i  30 ; ++$i) {
if ( $problem_class[$i] ne ) {
print option value=\$i\ $problem_class[$i]\n;
}
}
print /select\n;
 
 
 This produces something very close to this:
 
 select name=status
 option value=1 open
 option value=2 closed
 option value=3 testing
 /select
 
 select name=size
 option value=10 S
 option value=11 M
 option value=12 L
 option value=13 XL
 /select
 
 select name=color
 option value=20 Black
 option value=21 Red
 option value=22 Green
 option value=23 Blue
 /select
 
 
 If I could use something like this, it would allow me to produce different
 'for' statements for each select drop down I wanted to create.  One table
 to maintain, and change encase politics force me to change some of
 definitions with out having to do a massive sql update.  This works as
 long as the problem_class table is rather short (ie less than 1,000
 records).
 
 I know I am missing something 'obvious' in this.  Your help is
 appreciated.  Thank you.
 
 
 
 
 -- 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Chris Oxenreider | [EMAIL PROTECTED] | http://www.state.net/~oxenreid
  | MicroSoft Windows 2000: The De facto sub standard.
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]