[PHP] array problem

2011-09-09 Thread Marc Fromm
I am reading a csv file into an array. The csv file.

users.csv file contents:
w12345678,a
w23456789,b
w34567890,c

$csvfilename = users.csv;
$handle = fopen($csvfilename, r);
if($handle) {
while (($line = 
fgetcsv($handle, 1000, ,)) !== FALSE) {
$arrUsers[] = 
$line;
}
fclose($handle);
}

When I echo out the elements in the elements in the array $arrUsers I get:
Array
Array
Array

foreach ($arrUsers as $user){
echo $user . br /;
}

I can't figure out why the word Array is replacing the actual data.



Re: [PHP] array problem

2011-09-09 Thread Joshua Stoutenburg
The function fgetcsv() returns an array.

http://php.net/manual/en/function.fgetcsv.php


On Fri, Sep 9, 2011 at 9:00 AM, Marc Fromm marc.fr...@wwu.edu wrote:

 I am reading a csv file into an array. The csv file.

 users.csv file contents:
 w12345678,a
 w23456789,b
 w34567890,c

$csvfilename = users.csv;
 $handle = fopen($csvfilename, r);
if($handle) {
while (($line =
 fgetcsv($handle, 1000, ,)) !== FALSE) {
$arrUsers[]
 = $line;
}
fclose($handle);
}

 When I echo out the elements in the elements in the array $arrUsers I get:
 Array
 Array
 Array

 foreach ($arrUsers as $user){
echo $user . br /;
 }

 I can't figure out why the word Array is replacing the actual data.




Re: [PHP] array problem

2011-09-09 Thread Steve Staples
On Fri, 2011-09-09 at 16:00 +, Marc Fromm wrote:
 I am reading a csv file into an array. The csv file.
 
 users.csv file contents:
 w12345678,a
 w23456789,b
 w34567890,c
 
 $csvfilename = users.csv;
 $handle = fopen($csvfilename, r);
 if($handle) {
 while (($line = 
 fgetcsv($handle, 1000, ,)) !== FALSE) {
 $arrUsers[] = 
 $line;
 }
 fclose($handle);
 }
 
 When I echo out the elements in the elements in the array $arrUsers I get:
 Array
 Array
 Array
 
 foreach ($arrUsers as $user){
 echo $user . br /;
 }
 
 I can't figure out why the word Array is replacing the actual data.
 

Try print_r($arrUsers);

also, the $line is an array of the CSV, so you're storing an array,
within the array $arrUsers.

foreach ($arrUsers as $user){
foreach ($user as $val) {
echo $val . br /;
}
echo 'hr /';
}


-- 

Steve Staples
Web Application Developer
519.258.2333 x8414


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



Re: [PHP] array problem

2011-09-09 Thread Adam Balogh
hi,

try to use print_r or var_dump to echo compound data type


Re: [PHP] array problem

2011-09-09 Thread Ashley Sheridan
You are echoing out an array. If you use something like print_r() or var_dump() 
you will see the array elements
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

Marc Fromm marc.fr...@wwu.edu wrote:

I am reading a csv file into an array. The csv file.

users.csv file contents:
w12345678,a
w23456789,b
w34567890,c

$csvfilename = users.csv;
$handle = fopen($csvfilename, r);
if($handle) {
while (($line = fgetcsv($handle, 1000, ,)) !== FALSE) {
$arrUsers[] = $line;
}
fclose($handle);
}

When I echo out the elements in the elements in the array $arrUsers I get:
Array
Array
Array

foreach ($arrUsers as $user){
echo $user . br /;
}

I can't figure out why the word Array is replacing the actual data.



Re: [PHP] Array problem

2010-10-28 Thread Richard Quadling
On 27 October 2010 22:15, Kevin Kinsey k...@daleco.biz wrote:
 Marc Guay wrote:

 As Nicholas pointed out, the extra underscore in the key is the issue.

 That's way too easy a fix.  I think he should check to make sure his
 version of PHP was compiled with the right extensions and that the
 browser isn't doing something unpredictably bizarre when submitting
 the form.

 Just checked the card file, today's cause is: Sunspots.

 KDK


I always believed that cosmic radiation was the cause.


-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RE: [PHP] Array problem

2010-10-28 Thread Bob McConnell
From: Richard Quadling

 On 27 October 2010 22:15, Kevin Kinsey k...@daleco.biz wrote:
 Marc Guay wrote:

 As Nicholas pointed out, the extra underscore in the key is the issue.

 That's way too easy a fix.  I think he should check to make sure his
 version of PHP was compiled with the right extensions and that the
 browser isn't doing something unpredictably bizarre when submitting
 the form.

 Just checked the card file, today's cause is: Sunspots.
 
 I always believed that cosmic radiation was the cause.

I'll second the cosmic radiation. We are currently in the low activity portion 
of the 11 year sunspot cycle[1], and predictions of the next high are lower 
than most cycles recorded over the past century[2]. So that one is not an easy 
sell right now.

Bob McConnell

[1] http://www.windows2universe.org/sun/activity/sunspot_cycle.html
[2] http://solarscience.msfc.nasa.gov/predict.shtml

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



Re: [PHP] Array problem

2010-10-27 Thread Kevin Kinsey

Marc Guay wrote:

As Nicholas pointed out, the extra underscore in the key is the issue.


That's way too easy a fix.  I think he should check to make sure his
version of PHP was compiled with the right extensions and that the
browser isn't doing something unpredictably bizarre when submitting
the form.


Just checked the card file, today's cause is: Sunspots.

KDK

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



[PHP] array problem with a zencart shipping module

2008-02-06 Thread John Taylor-Johnston

I'm desperately going outside the forum, seeking help.
Does anyone have any experience with Zencart shipping modules, or 
understand arrays?

http://www.zen-cart.com/forum/showthread.php?t=87831
Its borrowed code and I,m not good at arrays to begin with.
Thanks,
John

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



Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread Nathan Nobbe
On Feb 6, 2008 11:11 PM, John Taylor-Johnston [EMAIL PROTECTED]
wrote:

 I'm desperately going outside the forum, seeking help.
 Does anyone have any experience with Zencart shipping modules, or
 understand arrays?
 http://www.zen-cart.com/forum/showthread.php?t=87831


maybe you should stick w/ that ajeh guy; he seems like he knows what hes
talking about.
also, people here dont typically just hand out help on generic questions
such as this; if you can get a specific question about php or a more focused
question than please help i dont know much about arrays, then maybe we
can help out..

http://www.zen-cart.com/forum/showthread.php?t=87831

 Its borrowed code and I,m not good at arrays to begin with.


ouch, maybe you need to hire someone ?  besides this has more to do than
just arrays; there is the rest of the application and clearly anyone whos
going
to help out must understand at least some of it..

-nathan


Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread John Taylor-Johnston

Thanks for the reply and checking it out.
I was hoping my problem lies only in the class.
I do have a Paypal account and at this point in time, it is a question 
of time - I've got to get my site in production and shut off the old cart.


Nathan Nobbe wrote:
On Feb 6, 2008 11:11 PM, John Taylor-Johnston 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


I'm desperately going outside the forum, seeking help.
Does anyone have any experience with Zencart shipping modules, or
understand arrays?
http://www.zen-cart.com/forum/showthread.php?t=87831


maybe you should stick w/ that ajeh guy; he seems like he knows what hes
talking about.
also, people here dont typically just hand out help on generic questions
such as this; if you can get a specific question about php or a more 
focused

question than please help i dont know much about arrays, then maybe we
can help out..

Its borrowed code and I,m not good at arrays to begin with.


ouch, maybe you need to hire someone ?  besides this has more to do than
just arrays; there is the rest of the application and clearly anyone 
whos going

to help out must understand at least some of it..

-nathan



Re: [PHP] array problem with a zencart shipping module

2008-02-06 Thread Paul Scott

On Wed, 2008-02-06 at 23:42 -0500, Nathan Nobbe wrote:
 ouch, maybe you need to hire someone ?  besides this has more to do than
 just arrays; there is the rest of the application and clearly anyone whos
 going
 to help out must understand at least some of it..

Yeah, I concur! You really should at least understand what you are doing
before attempting a shopping cart scenario where presumably people are
going to be trusting you/your code with their hard earned dough.

If you don't know arrays, then how exactly are you going to make sure
that the thing is secure?

I would _seriously_ consider taking Nathan's advice here and hiring
someone to do this for you or even with you. With you has the advantage
that next time, you will know, and be able to do it easier - as well as
learn something along the way.

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm 

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

[PHP] Array problem

2007-10-17 Thread Merlin

Hi there,

I am pulling picture ids out of a db and comment ids. The comments 
belong to the pic ids and are stored in two seperate tables.
I am having trouble with the arrays to display them after pulling out of 
the db.


The data is filled like this:

while (rows etc.){
$comment_id[$row-pic_id][] = $row-comment_id;
}

The goal is to cycle through that array and display the picture followed 
by the belonging comments:


Picture ID 1
-Comment 1 to pic_id 1
-Comment 2 to pic_id 1
-Comment 3 to pic_id 1

Picture ID 2
-Comment 1 to pic_id 2
-Comment 2 to pic_id 2

That does sound easy, but unfortunatelly I could not figure it out so far.

Can somebody give me a hint on how to cycle throug the arrays, or an 
alternative way to achive my goal?


Thank you for any help.

Best regards, Merlin

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



Re: [PHP] Array problem

2007-10-17 Thread Zoltán Németh
2007. 10. 17, szerda keltezéssel 13.08-kor Merlin ezt írta:
 Hi there,
 
 I am pulling picture ids out of a db and comment ids. The comments 
 belong to the pic ids and are stored in two seperate tables.
 I am having trouble with the arrays to display them after pulling out of 
 the db.
 
 The data is filled like this:
 
 while (rows etc.){
   $comment_id[$row-pic_id][] = $row-comment_id;
 }
 
 The goal is to cycle through that array and display the picture followed 
 by the belonging comments:
 
 Picture ID 1
 -Comment 1 to pic_id 1
 -Comment 2 to pic_id 1
 -Comment 3 to pic_id 1
 
 Picture ID 2
 -Comment 1 to pic_id 2
 -Comment 2 to pic_id 2
 
 That does sound easy, but unfortunatelly I could not figure it out so far.
 
 Can somebody give me a hint on how to cycle throug the arrays, or an 
 alternative way to achive my goal?

something like

$pic_ids = array_keys($comment_id);
foreach ($pic_ids as $pic_id) {
// echo image tag or what you want
foreach ($comment_id[$pic_id] as $comment) {
// echo comment or what you want
}
}

greets
Zoltán Németh

 
 Thank you for any help.
 
 Best regards, Merlin
 

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



RE: [PHP] Array problem

2007-10-17 Thread Ford, Mike
On 17 October 2007 12:09, Merlin wrote:

 Hi there,
 
 I am pulling picture ids out of a db and comment ids. The comments
 belong to the pic ids and are stored in two seperate tables.
 I am having trouble with the arrays to display them after
 pulling out of
 the db.
 
 The data is filled like this:
 
 while (rows etc.){
   $comment_id[$row-pic_id][] = $row-comment_id;
 }
 
 The goal is to cycle through that array and display the
 picture followed
 by the belonging comments:
 
 Picture ID 1
 -Comment 1 to pic_id 1
 -Comment 2 to pic_id 1
 -Comment 3 to pic_id 1
 
 Picture ID 2
 -Comment 1 to pic_id 2
 -Comment 2 to pic_id 2
 
 That does sound easy, but unfortunatelly I could not figure
 it out so far.
 
 Can somebody give me a hint on how to cycle throug the arrays, or an
 alternative way to achive my goal?

Something like this should work:

  foreach ($comment_id as $pic_id=$comment_ids):
echo Start of information for picture $pic_id;
foreach ($comment_ids as $com_id):
  echo Comment $com_id for picture $pic_id;
endforeach;
  endforeach;

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] array problem

2006-04-23 Thread Brian V Bonini
On Sat, 2006-04-22 at 15:31, Martin Alterisio wrote:
 You're wrong, he isn't using an associative array, since the keys used
 are only integers.

Well, if you really want to argue semantics then technically we're both
wrong because there are no different indexed and associative array types
in PHP, what was that you said?...  (read the manual!!!)

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



Re: [PHP] array problem + humor (all those with joke allergies beware)

2006-04-23 Thread Brian V Bonini
On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
 with regard to Suresh - do you, Brian, know how many times he has posted 
 similar
 question to this list this year? (this is the first time he has even given
 an indication that he knows where the manual is let alone opened it btw) do 
 you
 know how many times he's been waiting for a reply/answer? how many times 
 people
 have given him answered? how often he has replied (like saying thank you for
 instance) to anyone of the repsonses to his questions in any form whatsovever?
 

Did you need some recommendations on a new email program? Most have a
delete button, not sure how the authors of yours missed that

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



Re: [PHP] array problem + humor (all those with joke allergies beware)

2006-04-23 Thread Dave Goodchild
Tiresome.

On 23/04/06, Brian V Bonini [EMAIL PROTECTED] wrote:

 On Sat, 2006-04-22 at 14:16, Jochem Maas wrote:
  with regard to Suresh - do you, Brian, know how many times he has posted
 similar
  question to this list this year? (this is the first time he has even
 given
  an indication that he knows where the manual is let alone opened it btw)
 do you
  know how many times he's been waiting for a reply/answer? how many times
 people
  have given him answered? how often he has replied (like saying thank you
 for
  instance) to anyone of the repsonses to his questions in any form
 whatsovever?
 

 Did you need some recommendations on a new email program? Most have a
 delete button, not sure how the authors of yours missed that

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




--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!


[PHP] array problem

2006-04-22 Thread suresh kumar
 sorry.earlier i mistyped some values. 
   
  I am facing one project in my project .
   
  this is my  code:
   
  a=array(0=10,1=10,2=40,3=30,4=30,5=10);
  b=array();
  b=array_unique($a);
  print_r($b); 
  o/p  getting from above code is  b[0]=10,b[2]=40,b[3]=30,b[5]=10;
   
  but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
   
  i searched php.net .i am not able to fine any solution.i am breaking 
my head for last  5 hours.i am waiting reply from any one
   



-
 Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Re: [PHP] array problem

2006-04-22 Thread Brian V Bonini
On Sat, 2006-04-22 at 07:09, suresh kumar wrote:
  sorry.earlier i mistyped some values. 

   I am facing one project in my project .

   this is my  code:

   a=array(0=10,1=10,2=40,3=30,4=30,5=10);
   b=array();
   b=array_unique($a);
   print_r($b); 
   o/p  getting from above code is  b[0]=10,b[2]=40,b[3]=30,b[5]=10;

   but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;


That will return:

Array
(
[0] = 10
[2] = 40
[3] = 30
)

If you want:

Array
(
[0] = 10
[1] = 40
[2] = 30
)


Don't use an associative array for $a 
$a=array(10,10,40,30,30,10);

Or iterate through $a to re-sequence the index in $b.

$a=array(0=10,1=10,2=40,3=30,4=30,5=10);
$a=array_unique($a);

foreach($a as $v) {
$b[] = $v;
}

print_r($b);

-- 

s/:-[(/]/:-)/g


BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
Key Info: http://gfx-design.com/keys
Linux Registered User #339825 at http://counter.li.org

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



Re: [PHP] array problem + humor (all those with joke allergies beware)

2006-04-22 Thread Jochem Maas

suresh kumar wrote:
 sorry.earlier i mistyped some values. 
   
  I am facing one project in my project .
   
  this is my  code:
   
  a=array(0=10,1=10,2=40,3=30,4=30,5=10);

  b=array();
  b=array_unique($a);
  print_r($b); 
  o/p  getting from above code is  b[0]=10,b[2]=40,b[3]=30,b[5]=10;


the OUTPUT is not what you say it is - why don't you take 5 seconds
to cut and paste the *actual* output of print_r() ???

in fact if your going to send some code - THEN SEND SOME CODE and
not some hastily typed psuedo code that doesn't run (notice the missing
dollar signs in front variaous variables??)

   
  but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
   
  i searched php.net .i am not able to fine any solution.i am breaking 
my head for last  5 hours.


you may have searched but you didn't read very far - in five hours it's
probably possible to read every about arrays on php.net; but anyway read the 
following
2 pages over and over until you fully understand them - understanding php's
array datatype is practically the foundation to getting anywhere with php:

http://php.net/manual/en/language.types.array.php
http://php.net/manual/en/function.array-values.php


i am waiting reply from any one


tell every one here that your waiting does come accross very well -
I'd stop saying it if I we're you.

get the feeling I'm picking on you? well your absolutely right,
you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
oddball. Anytime you come to this list I'm going to beat programming ethic
into you until you 'get it' - either you'll end up looking like something
that resembles a real coder OR I'll end up start a inter-continental racewar -
lets see how it pans out.

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



Re: [PHP] array problem + humor (all those with joke allergies beware)

2006-04-22 Thread Brian V Bonini
Jochem's site:

 snip 
http://iamjochem.com/mariecke/index.php

Mariecke's daily ramblings (almost) in dutch  english... this page is
using output from a drupal system.
If nothing else they have a nice logo. ;)


Warning: main(./../blog/parse.php): failed to open stream: No such file
or directory in /home/sites/com/moulin/iamjochem/www/mariecke/blog.php
on line 24

Warning: main(): Failed opening './../blog/parse.php' for inclusion
(include_path='.:/usr/share/php4:/usr/share/php') in
/home/sites/com/moulin/iamjochem/www/mariecke/blog.php on line 24

Fatal error: Call to undefined function: parse_feed() in
/home/sites/com/moulin/iamjochem/www/mariecke/blog.php on line 25

 // snip 

Perhaps you should take some of your own *advice*... ???

[EMAIL PROTECTED]  /dev/null

On Sat, 2006-04-22 at 09:48, Jochem Maas wrote:
 suresh kumar wrote:
   sorry.earlier i mistyped some values. 
 
I am facing one project in my project .
 
this is my  code:
 
a=array(0=10,1=10,2=40,3=30,4=30,5=10);
b=array();
b=array_unique($a);
print_r($b); 
o/p  getting from above code is  b[0]=10,b[2]=40,b[3]=30,b[5]=10;
 
 the OUTPUT is not what you say it is - why don't you take 5 seconds
 to cut and paste the *actual* output of print_r() ???
 
 in fact if your going to send some code - THEN SEND SOME CODE and
 not some hastily typed psuedo code that doesn't run (notice the missing
 dollar signs in front variaous variables??)
 
 
but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;
 
i searched php.net .i am not able to fine any solution.i am breaking 
  my head for last  5 hours.
 
 you may have searched but you didn't read very far - in five hours it's
 probably possible to read every about arrays on php.net; but anyway read the 
 following
 2 pages over and over until you fully understand them - understanding php's
 array datatype is practically the foundation to getting anywhere with php:
 
 http://php.net/manual/en/language.types.array.php
 http://php.net/manual/en/function.array-values.php
 
  i am waiting reply from any one
 
 tell every one here that your waiting does come accross very well -
 I'd stop saying it if I we're you.
 
 get the feeling I'm picking on you? well your absolutely right,
 you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
 oddball. Anytime you come to this list I'm going to beat programming ethic
 into you until you 'get it' - either you'll end up looking like something
 that resembles a real coder OR I'll end up start a inter-continental racewar -
 lets see how it pans out.

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



Re: [PHP] array problem + humor (all those with joke allergies beware)

2006-04-22 Thread Jochem Maas

thanks Brian.

that site has not worked for, oh, 3 years - I don't see what some broken
code on some site I haven't done anything with in years has got to do
with programmer ethic (or whatever advice you were refering to).
- am I bugging you for a fix?

with regard to Suresh - do you, Brian, know how many times he has posted similar
question to this list this year? (this is the first time he has even given
an indication that he knows where the manual is let alone opened it btw) do you
know how many times he's been waiting for a reply/answer? how many times people
have given him answered? how often he has replied (like saying thank you for
instance) to anyone of the repsonses to his questions in any form whatsovever?

answers: 30+, 30+, 50+, 0

so if you want me to fix some 3y/o unused blog, that my girlfriend has
no time for, your  out of luck.

what was the question again :-)

Brian V Bonini wrote:

Jochem's site:



...



Perhaps you should take some of your own *advice*... ???

[EMAIL PROTECTED]  /dev/null



...


get the feeling I'm picking on you? well your absolutely right,
you non-responding, dumb-question-asking, lack-of-problem-solving-initiative
oddball. Anytime you come to this list I'm going to beat programming ethic
into you until you 'get it' - either you'll end up looking like something
that resembles a real coder OR I'll end up start a inter-continental racewar -
lets see how it pans out.





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



Re: [PHP] array problem

2006-04-22 Thread Martin Alterisio
You're wrong, he isn't using an associative array, since the keys used are
only integers.

array(10,10,40,30,30,10);
and
array(0=10,1=10,2=40,3=30,4=30,5=10);
create the same array.

The problem is that array_unique preserves keys (read the manual!!!)
If you don't want this, use array_values() to turn the array into a more
traditional array:

$a = array_values(array_unique($a));


2006/4/22, Brian V Bonini [EMAIL PROTECTED]:

 On Sat, 2006-04-22 at 07:09, suresh kumar wrote:
   sorry.earlier i mistyped some values.
 
I am facing one project in my project .
 
this is my  code:
 
a=array(0=10,1=10,2=40,3=30,4=30,5=10);
b=array();
b=array_unique($a);
print_r($b);
o/p  getting from above code is  b[0]=10,b[2]=40,b[3]=30,b[5]=10;
 
but i want the o/p be b[0]=10,b[1]=40,b[2]=30,b[3]=10;


 That will return:

 Array
 (
 [0] = 10
 [2] = 40
 [3] = 30
 )

 If you want:

 Array
 (
 [0] = 10
 [1] = 40
 [2] = 30
 )


 Don't use an associative array for $a
 $a=array(10,10,40,30,30,10);

 Or iterate through $a to re-sequence the index in $b.

 $a=array(0=10,1=10,2=40,3=30,4=30,5=10);
 $a=array_unique($a);

 foreach($a as $v) {
 $b[] = $v;
 }

 print_r($b);

 --

 s/:-[(/]/:-)/g


 BrianGnuPG - KeyID: 0x04A4F0DC | Key Server: pgp.mit.edu
 ==
 gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
 Key Info: http://gfx-design.com/keys
 Linux Registered User #339825 at http://counter.li.org

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




Re: [PHP] Array problem

2005-03-26 Thread [EMAIL PROTECTED]
May be this help you:
$data=$_POST['position'];
$positions=array_keys($data);
foreach($positions as $pos){
   $row=$data[$pos];
   foreach($row as $value){
  $sql=INSERT INTO table_name (field_name)VALUES ('$value');
  $cursor=mysql_query($sql);
   }
}
Devta.
[EMAIL PROTECTED] escribió:
Hi,
I have a form like this:
form action=products.php method=post
input name=position[pos][value 1]  type=text  id=position[pos][value 1]  
value=number 1
input name=position[pos][value 2]  type=text  id=position[pos][value 2]  
value=number 2
input name=position[pos][value 3]  type=text  id=position[pos][value 3]  
value=number 3
/form
For each element of the array i want to update the value in the database. For 
example, for position[pos][value 1] i want to update the value (number 1) in 
the database.
Thanks in advance for your help!!!
 


No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005
 




[PHP] Array problem

2005-03-25 Thread virtualsoftware
Hi,
I have a form like this:
form action=products.php method=post
input name=position[pos][value 1]  type=text  id=position[pos][value 1]  
value=number 1
input name=position[pos][value 2]  type=text  id=position[pos][value 2]  
value=number 2
input name=position[pos][value 3]  type=text  id=position[pos][value 3]  
value=number 3
/form

For each element of the array i want to update the value in the database. For 
example, for position[pos][value 1] i want to update the value (number 1) in 
the database.

Thanks in advance for your help!!!

[PHP] array problem

2005-01-21 Thread Ahmed Abdel-Aliem
hi
if i have an array 

$listing1 = array(array('title'='yahoo', 'redirect'='www.yahoo.com',
'info'='yahoo website'), array(title='msn',
'redirect'='www.msn.com', 'info='msn website'));

$listing2 = array(array('name'='lycos', 'link'='www.lycos.com',
'description'='lycos website'), array(name='me2resh',
'link'='www.me2resh.com', 'description'='me2resh website'));

how can i group them together into one array to be :

$listing3 = array(array('header'='lycos', 'url'='www.lycos.com',
'information'='lycos website'), array(header='me2resh',
'url'='www.me2resh.com', 'information'='me2resh website'),
array('header'='lycos', 'url'='www.lycos.com', 'information'='lycos
website'), array(header='me2resh', 'url'='www.me2resh.com',
'information'='me2resh website'));

and then how can i sort them by the value of information for example
can anyone help me please with this ?


Ahmed Abdel-Aliem
Web Developer
www.ApexScript.com
0101108551

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



Re: [PHP] array problem

2005-01-21 Thread Richard Lynch
Ahmed Abdel-Aliem wrote:
 how can i group them together into one array to be :

http://php.net/array_merge

and friends should help

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Array problem

2004-06-14 Thread Brent Clark
Hi all

I have this problem whereby im try to create some kind of an array of a
split off a file.

//Here I pull the file in the array $contents.

$contents = file($hotelpathprod.$hotel);

foreach($contents as $arr=$conts){
$ff[] = split(\|,$conts); //Here im trying to do a split 
on the file
}

Now this the array $ff is fine, the catch is now, it that, the first element
has a have like p101.
What I trying to do is do a substr($abc,1) and the take that value and make
that the number of the element I want.

This is what I was going with.

foreach($ff as $qaz=$wsx){
$ffile[substr($qaz[0],1)]=$qaz[0];
}

If anyone could assist, it would really be appreciated.

Kind Regards
Brent Clark

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



Re: [PHP] Array Problem

2004-04-18 Thread Don Read

On 16-Apr-2004 Flavio Fontana wrote:
 Hi
 
 I have i Problem i got a variable a=2351 now i need to create an
 array out of this variable 
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1
 
 I have an idea to use the modulo function an do some Math but im sure
 there is a nicer way of solving my prob
 

$a = preg_split('||', $a, -1, PREG_SPLIT_NO_EMPTY);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

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



[PHP] Array Problem

2004-04-17 Thread Flavio Fontana
Hi

I have i Problem i got a variable a=2351 now i need to create an array out of this 
variable 
a[0]=1
a[1]=3
a[2]=5
a[3]=1

I have an idea to use the modulo function an do some Math but im sure there is a nicer 
way of solving my prob

thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
That's how you could do it ...

$ar = array();

$len = strlen($a);
for ($i = 0; $i  $len; ++$i) {
$ar[] = $a{$i};
}

HTH

Richard



Friday, April 16, 2004, 11:00:49 PM, you wrote:

 Hi

 I have i Problem i got a variable a=2351 now i need to create an array out of this 
 variable
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1

 I have an idea to use the modulo function an do some Math but im
 sure there is a nicer way of solving my prob

 thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Arthur Radulescu
 That's how you could do it ...
 
 $ar = array();
 
 $len = strlen($a);
 for ($i = 0; $i  $len; ++$i) {
 $ar[] = $a{$i};
 }

If I remember well strlen is used for checking the length of a string...


Arthur



Looking for a job!? Use the smart search engine!!
Find a Job from Millions WorldWide... 
http://search.jobsgrabber.com


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



Re: [PHP] Array Problem

2004-04-17 Thread Daniel Clark
How about count()

That's how you could do it ...

$ar = array();

$len = strlen($a);
for ($i = 0; $i  $len; ++$i) {
$ar[] = $a{$i};
}

HTH

Richard

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



Re: [PHP] Array Problem

2004-04-17 Thread Richard Harb
Saturday, April 17, 2004, 7:38:46 PM, Arthur Radulescu wrote:

 That's how you could do it ...
 
 $ar = array();
 
 $len = strlen($a);
 for ($i = 0; $i  $len; ++$i) {
 $ar[] = $a{$i};
 }

 If I remember well strlen is used for checking the length of a string...

It does ...
I didn't look closely enough :(
So .. the var has to be converted to str first ... or use a temp var
converted to string ...

except of course someone comes up with a better method of solving the
problem at hand.



just for reference: the original problem (as I now understand it) was
how to 'convert' a number into an array ...


Friday, April 16, 2004, 11:00:49 PM, Flavio Fontana wrote:

 Hi

 I have i Problem i got a variable a=2351 now i need to create an array out of this 
 variable
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1

 I have an idea to use the modulo function an do some Math but im
 sure there is a nicer way of solving my prob

 thx Flavio

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



Re: [PHP] Array Problem

2004-04-17 Thread Tom Rogers
Hi,

Saturday, April 17, 2004, 7:00:49 AM, you wrote:
FF Hi

FF I have i Problem i got a variable a=2351 now i need to create an array out of this 
variable
FF a[0]=1
FF a[1]=3
FF a[2]=5
FF a[3]=1

FF I have an idea to use the modulo function an do some Math but
FF im sure there is a nicer way of solving my prob

FF thx Flavio


If you treat the variable as a string it is already an array of
characters

try echo $a{0};

-- 
regards,
Tom

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



Re: [PHP] Array problem

2004-03-22 Thread Firman Wandayandi
Hi noginn,

$columntotals[$count] = $columntotals[$count] + $sum;
 ^-^
   ERROR HERE

Seem you tried to assign columntotal[index]  with itself and you never
defined it. You should tried this one.

= $columntotals[$count] = $sum;

Is right?

Sorry, I confuse with your words total of totals?

Good Luck,
Firman

- Original Message -
From: noginn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 22, 2004 12:33 AM
Subject: [PHP] Array problem


 This has been confusing me a little for a few hours now.

 Heres a snip of my code which is causing the problem:

 $content = table border='0' cellspacing='0' cellpadding='5'\n;
 $content .= tr\n;
 $content .= tdnbsp;/td\n;

 $tasks = new dbconnect;
 $tasks-connect();
 $tasks-query(SELECT tid, tname FROM tasks);
 while(list($tid, $tname) = $tasks-fetch_rows()) {
 $content .= td valign='top' align='center'span
 class='highlight'$tname/span/td\n;
 }
 $content .= tdnbsp;/td\n;
 $content .= /tr\n;

 $projects = new dbconnect;
 $projects-connect();
 $projects-query(SELECT pid, pname FROM projects);

* $columntotals = array();*
 $colour = 0;

 while(list($pid, $pname) = $projects-fetch_rows()) {
 $tasks-data_seek(0);
 $rowtotal = 0;
 $count = 0;
 if ($colour % 2) {
 $bgcolour = #FF;
 }
 else {
 $bgcolour = #F9F9F9;
 }
 $colour++;
 $content .= tr\n;
 $content .= td valign='top' align='center'span
 class='highlight'$pname/span/td\n;

 while(list($tid, $tname) = $tasks-fetch_rows()) {
 $logs = new dbconnect;
 $logs-connect();
 $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid'
 AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
 list($sum) = $logs-fetch_rows();

 if (!$sum) {
 $sum = 0;
 }

 $rowtotal = $rowtotal + $sum;
 *$columntotals[$count] = $columntotals[$count] + $sum;*
 $count++;

 $content .= td bgcolor='$bgcolour'
 align='center'$sum/td\n;
 }
 $content .= td align='center'b$rowtotal/b/td\n;
 }
 $content .= /tr\n;
 $content .= tr\n;
 $content .= tdnbsp;/td\n;

 $sumofcolumntotals = 0;

 for ($i=0; $isizeof($columntotals); $i++)
 {
 $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
 $content .= td align='center'b$columntotals[$i]/b/td\n;
 }

 $content .= td align='center'b$sumofcolumntotals/b/td\n;
 $content .= /tr\n;
 $content .= /table\n;

 I have made the lines inwhich I know are causing problems in bold.
 Basicly, I am creating a report of some data and need to count up totals
 of each column and then again total the totals if you get me.
 Here is the errors I am getting.
 *Notice*: Undefined offset: 0 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 1 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 2 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
 *Notice*: Undefined offset: 3 in
 *C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58

 *Now I understand in a way why its happening, because im trying to
 insert into $columntotals something which isnt valid, but I can't think
 of a way to stop this at the moment.
 Hope to hear soon, thanks in advance guys.

 -noginn

 --
 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] Array problem

2004-03-22 Thread noginn
Ye that is true, however to create the totals of each columns I had to 
somehow do this.
I have fixed the problem in a way, but it was probably a very crude way 
of doing so.

   $rowtotal = $rowtotal + $sum;
   if(!empty($columntotals[$count])) {
   $columntotals[$count] = $columntotals[$count] + $sum;
   }
   else {
   $columntotals[$count] = $sum;
   }
   $count++;
So now it won't try and add itself if it is empty.
But if anyone has more ideas of how I can create a cleaner piece of code 
then please let me know! :)

-noginn

Firman Wandayandi wrote:

Hi noginn,

$columntotals[$count] = $columntotals[$count] + $sum;
^-^
  ERROR HERE
Seem you tried to assign columntotal[index]  with itself and you never
defined it. You should tried this one.
= $columntotals[$count] = $sum;

Is right?

Sorry, I confuse with your words total of totals?

Good Luck,
   Firman
- Original Message -
From: noginn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 22, 2004 12:33 AM
Subject: [PHP] Array problem
 

This has been confusing me a little for a few hours now.

Heres a snip of my code which is causing the problem:

   $content = table border='0' cellspacing='0' cellpadding='5'\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
   $tasks = new dbconnect;
   $tasks-connect();
   $tasks-query(SELECT tid, tname FROM tasks);
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $content .= td valign='top' align='center'span
class='highlight'$tname/span/td\n;
   }
   $content .= tdnbsp;/td\n;
   $content .= /tr\n;
   $projects = new dbconnect;
   $projects-connect();
   $projects-query(SELECT pid, pname FROM projects);
  * $columntotals = array();*
   $colour = 0;
   while(list($pid, $pname) = $projects-fetch_rows()) {
   $tasks-data_seek(0);
   $rowtotal = 0;
   $count = 0;
   if ($colour % 2) {
   $bgcolour = #FF;
   }
   else {
   $bgcolour = #F9F9F9;
   }
   $colour++;
   $content .= tr\n;
   $content .= td valign='top' align='center'span
class='highlight'$pname/span/td\n;
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $logs = new dbconnect;
   $logs-connect();
   $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid'
AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
   list($sum) = $logs-fetch_rows();
   if (!$sum) {
   $sum = 0;
   }
   $rowtotal = $rowtotal + $sum;
   *$columntotals[$count] = $columntotals[$count] + $sum;*
   $count++;
   $content .= td bgcolor='$bgcolour'
align='center'$sum/td\n;
   }
   $content .= td align='center'b$rowtotal/b/td\n;
   }
   $content .= /tr\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
   $sumofcolumntotals = 0;

   for ($i=0; $isizeof($columntotals); $i++)
   {
   $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
   $content .= td align='center'b$columntotals[$i]/b/td\n;
   }
   $content .= td align='center'b$sumofcolumntotals/b/td\n;
   $content .= /tr\n;
   $content .= /table\n;
I have made the lines inwhich I know are causing problems in bold.
Basicly, I am creating a report of some data and need to count up totals
of each column and then again total the totals if you get me.
Here is the errors I am getting.
*Notice*: Undefined offset: 0 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 1 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 2 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 3 in
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58
*Now I understand in a way why its happening, because im trying to
insert into $columntotals something which isnt valid, but I can't think
of a way to stop this at the moment.
Hope to hear soon, thanks in advance guys.
-noginn

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





 




[PHP] Array problem

2004-03-21 Thread noginn
This has been confusing me a little for a few hours now.

Heres a snip of my code which is causing the problem:

   $content = table border='0' cellspacing='0' cellpadding='5'\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
  
   $tasks = new dbconnect;
   $tasks-connect();
   $tasks-query(SELECT tid, tname FROM tasks);
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $content .= td valign='top' align='center'span 
class='highlight'$tname/span/td\n;
   }
   $content .= tdnbsp;/td\n;
   $content .= /tr\n;
  
   $projects = new dbconnect;
   $projects-connect();
   $projects-query(SELECT pid, pname FROM projects);
  
  * $columntotals = array();*
   $colour = 0;
  
   while(list($pid, $pname) = $projects-fetch_rows()) {
   $tasks-data_seek(0);
   $rowtotal = 0;
   $count = 0;
   if ($colour % 2) {
   $bgcolour = #FF;
   }
   else {
   $bgcolour = #F9F9F9;
   }
   $colour++;
   $content .= tr\n;
   $content .= td valign='top' align='center'span 
class='highlight'$pname/span/td\n;
  
   while(list($tid, $tname) = $tasks-fetch_rows()) {
   $logs = new dbconnect;
   $logs-connect();
   $logs-query(SELECT SUM(hours) from logs WHERE pid = '$pid' 
AND tid = '$tid' AND date = '$sdate' AND date = '$edate');
   list($sum) = $logs-fetch_rows();
  
   if (!$sum) {
   $sum = 0;
   }
  
   $rowtotal = $rowtotal + $sum;
   *$columntotals[$count] = $columntotals[$count] + $sum;*
   $count++;
  
   $content .= td bgcolor='$bgcolour' 
align='center'$sum/td\n;
   }
   $content .= td align='center'b$rowtotal/b/td\n;
   }
   $content .= /tr\n;
   $content .= tr\n;
   $content .= tdnbsp;/td\n;
  
   $sumofcolumntotals = 0;
  
   for ($i=0; $isizeof($columntotals); $i++)
   {
   $sumofcolumntotals = $sumofcolumntotals + $columntotals[$i];
   $content .= td align='center'b$columntotals[$i]/b/td\n;
   }

   $content .= td align='center'b$sumofcolumntotals/b/td\n;
   $content .= /tr\n;
   $content .= /table\n;
I have made the lines inwhich I know are causing problems in bold. 
Basicly, I am creating a report of some data and need to count up totals 
of each column and then again total the totals if you get me.
Here is the errors I am getting.
*Notice*: Undefined offset: 0 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 1 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 2 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58*
*Notice*: Undefined offset: 3 in 
*C:\WWW\Apache2\htdocs\php\coursework\reports_projects.php* on line *58

*Now I understand in a way why its happening, because im trying to 
insert into $columntotals something which isnt valid, but I can't think 
of a way to stop this at the moment.
Hope to hear soon, thanks in advance guys.

-noginn

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


Re: [PHP] Array problem....

2003-12-11 Thread Jas
Well just so you understand why I needed something like that here is 
the finished result below

?php
function show() {
	require 'path/to/dbconnector.inc';
	$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or die(mysql_error());		
	   $i = 0;
	   while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
		   $_SESSION[$i] = subnet $subbrnetmask $msk {broption 
domain-name-servers $dns01, $dns02;broption routers $rtrs;brrange 
$rnge;br}br;
		   $i++; }
?

Then ...
?php
call_user_func(show);
echo $_session['0'];
echo $_session['1'];
...
?
And you get...
subnet 128.110.22.110
netmask 255.255.255.0 {
option domain-name-servers 128.110.22.4, 128.110.29.3;
option routers 128.110.22.1;
range ;
}
Which allows for easy reading of configuration variables and the ability 
to modify the individual vars using a form etc.

Thanks again for all who gave me some pointers on using numbers instead 
of names for my session vars.
Jas

Chris W. Parker wrote:
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:44 PM said:

having no idea you could use numbers as session variable names I kinda
feel like a retard right now.  You solution worked, thank you very
much.


It's an array just like any other which you probably realize now. ;)

Also, unless you're doing some math or something with those variables
you might to split them up into their own cells (I don't really know if
this is going to be useful for you or not):
{
$_SESSION[$iCtr]['var1'] = $var1;
$_SESSION[$iCtr]['var2'] = $var2;
$_SESSION[$iCtr]['var3'] = $var3;
$_SESSION[$iCtr]['var4'] = $var4;
$_SESSION[$iCtr]['var5'] = $var5;
...
}


HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Array problem....

2003-12-11 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Thursday, December 11, 2003 7:21 AM said:

 Well just so you understand why I needed something like that here is
 the finished result below

[snip]

 $i = 0;
 while(list(...) = mysql_fetch_row(...)) {
 $_SESSION[$i] = ...;
 $i++;
 }

I want to change my suggestion and recommend that you go along with what
John Holmes suggested a little after my post. Read his post again and
see if it is helpful to you. Keep note of the following aspect:

You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
...; to $_SESSION[] = ...;.

i.e. The following two code blocks perform the same task:

Current:
$i = 0;
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[$i] = ...;
$i++;
}

New:
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[] = ...;
}



Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] Array problem....

2003-12-11 Thread Jas
Yeah I understand that and it would be perfect if I only had to call 
this type of function once on a page... and on any other pages that need 
something like this I will do it that way but with the counter set to 0 
or whatever number I choose which is a sort of view all page so your 
solutions works better for this page.  Thanks again.
Jas

Chris W. Parker wrote:

Jas mailto:[EMAIL PROTECTED]
on Thursday, December 11, 2003 7:21 AM said:

Well just so you understand why I needed something like that here is
the finished result below


[snip]


$i = 0;
while(list(...) = mysql_fetch_row(...)) {
   $_SESSION[$i] = ...;
   $i++;
}


I want to change my suggestion and recommend that you go along with what
John Holmes suggested a little after my post. Read his post again and
see if it is helpful to you. Keep note of the following aspect:
You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] =
...; to $_SESSION[] = ...;.
i.e. The following two code blocks perform the same task:

Current:
$i = 0;
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[$i] = ...;
$i++;
}
New:
while(list(...) = mysql_fetch_row(...)) {
$_SESSION[] = ...;
}


Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Array problem....

2003-12-10 Thread Jas
Not very good at arrays so I figured i would look here

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error());	 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
	print $sub;
	print br;
	print $msk;
	print br;
	print $dns01;
	print br;
	print $dns02;
	print brbr; }
?

This pulls each row form a table and assigns a variable to each field, 
but what I need to do is something like this...

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error());	 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
	$_session['something to automaticly increment session var'] = 
$sub+$msk+$dns01...
}

I have been scouring the various functions and as of yet have yet to 
accomplish what I need.  Any help would be great.
Thanks in advance,
jas

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


RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:21 PM said:

 while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) =
 mysql_fetch_row($sql_subs)) {
   $_session['something to automaticly increment session var'] =
 $sub+$msk+$dns01...
 }

No exactly sure what you mean but here goes:

$iCtr = 0;

while(list(...)) = mysql_fetch_row(...))
{
$_SESSION[$iCtr] = $sub+$msk...;
$iCtr++;
}


HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Chris W. Parker 
on Wednesday, December 10, 2003 3:27 PM said:

 while(list(...)) = mysql_fetch_row(...))
 {

Got one too many ) in there. Should be:

while(list(...) = mysql_fetch_row(...))
{



Chris.

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



Re: [PHP] Array problem....

2003-12-10 Thread Jas
having no idea you could use numbers as session variable names I kinda 
feel like a retard right now.  You solution worked, thank you very much.
Jas

Chris W. Parker wrote:

Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:21 PM said:

while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) =
mysql_fetch_row($sql_subs)) {
$_session['something to automaticly increment session var'] =
$sub+$msk+$dns01...
}


No exactly sure what you mean but here goes:

$iCtr = 0;

while(list(...)) = mysql_fetch_row(...))
{
$_SESSION[$iCtr] = $sub+$msk...;
$iCtr++;
}
HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Array problem....

2003-12-10 Thread Chris W. Parker
Jas mailto:[EMAIL PROTECTED]
on Wednesday, December 10, 2003 3:44 PM said:

 having no idea you could use numbers as session variable names I kinda
 feel like a retard right now.  You solution worked, thank you very
 much.

It's an array just like any other which you probably realize now. ;)

Also, unless you're doing some math or something with those variables
you might to split them up into their own cells (I don't really know if
this is going to be useful for you or not):

{
$_SESSION[$iCtr]['var1'] = $var1;
$_SESSION[$iCtr]['var2'] = $var2;
$_SESSION[$iCtr]['var3'] = $var3;
$_SESSION[$iCtr]['var4'] = $var4;
$_SESSION[$iCtr]['var5'] = $var5;
...
}



HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] Array problem....

2003-12-10 Thread John W. Holmes
Jas wrote:

but what I need to do is something like this...

?php
$sql_subs = mysql_query(SELECT * FROM $t_02,$db)or 
die(mysql_error()); 
while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = 
mysql_fetch_row($sql_subs)) {
$_session['something to automaticly increment session var'] = 
$sub+$msk+$dns01...
}
How about:

$sql_subs = mysql_query(SELECT * FROM $t_02,$db) or die(mysql_error());
while($row = mysql_fetch_row($sql_subs))
{ $_SESSION['data'][] = $row; }
and you can use $_SESSION['data'][1]['id'], $_SESSION['data'][1]['sub'], 
etc...

If you really want a + delimited string in the session, then you can use:

$_SESSION['data'][] = implode('+',$row);

Then row 1 is $_SESSION['data'][0], row 2 is $_SESSION['data'][1], etc.

Kind of begs the question of why you're doing all this, though

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


[PHP] Array problem in PHP. Please help.

2001-07-12 Thread Michael Champagne

Ok, here's the print_r() output of my 2 arrays.  The first really just has an
extra dimension.  How can I get the format of the first one looking like the
bottom one (just an array of key = value pairs)?

Thanks!

Array ( [0] = Array ( [trade_date] = Trade Date )
[1] = Array ( [settle_date] = Settlement Date )
[2] = Array ( [symbol] = Symbol )
[3] = Array ( [blank] = Blank Field )
[4] = Array ( [account] = Broker Account )
[5] = Array ( [symbol_desc] = Symbol Description )
[6] = Array ( [symbol_desc] = Symbol Description )
[7] = Array ( [first_money] = First Money ) )

Array ( [trade_date] = Trade Date
[settle_date] = Settlement Date
[symbol] = Symbol
[account] = Broker Account
[symbol_desc] = Symbol Description
[first_money] = First Money
[buy_sell] = Buy/Sell [comm] )


-- 
Michael Champagne, Software Engineer
Capital Institutional Services, Inc.
wk: [EMAIL PROTECTED]
hm: [EMAIL PROTECTED]



**
This communication is for informational purposes only.  It is not
intended as an offer or solicitation for the purchase or sale of 
any financial instrument or as an official confirmation of any 
transaction, unless specifically agreed otherwise.  All market 
prices, data and other information are not warranted as to 
completeness or accuracy and are subject to change without
notice.  Any comments or statements made herein do not 
necessarily reflect the views or opinions of Capital Institutional
Services, Inc.  Capital Institutional Services, Inc. accepts no
liability for any errors or omissions arising as a result of
transmission.  Use of this communication by other than intended
recipients is prohibited.
**

-- 
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] Array problem in PHP. Please help.

2001-07-12 Thread Adrian Ciutureanu

foreach($oldArray as $a)) {
list($key, $value) = each($a);
$newArray[$key] = $value;
}


 -Original Message-
 From: Michael Champagne [mailto:[EMAIL PROTECTED]]
 Sent: 12 iulie 2001 17:37
 To: PHP General Mailing List
 Subject: [PHP] Array problem in PHP. Please help.
 
 
 Ok, here's the print_r() output of my 2 arrays.  The first 
 really just has an
 extra dimension.  How can I get the format of the first one 
 looking like the
 bottom one (just an array of key = value pairs)?
 
 Thanks!
 
 Array ( [0] = Array ( [trade_date] = Trade Date )
 [1] = Array ( [settle_date] = Settlement Date )
   [2] = Array ( [symbol] = Symbol )
   [3] = Array ( [blank] = Blank Field )
   [4] = Array ( [account] = Broker Account )
   [5] = Array ( [symbol_desc] = Symbol Description )
   [6] = Array ( [symbol_desc] = Symbol Description )
   [7] = Array ( [first_money] = First Money ) )
 
 Array ( [trade_date] = Trade Date
 [settle_date] = Settlement Date
   [symbol] = Symbol
   [account] = Broker Account
   [symbol_desc] = Symbol Description
   [first_money] = First Money
   [buy_sell] = Buy/Sell [comm] )
 
 
 -- 
 Michael Champagne, Software Engineer
 Capital Institutional Services, Inc.
 wk: [EMAIL PROTECTED]
 hm: [EMAIL PROTECTED]
 
 
 
 **
 This communication is for informational purposes only.  It is not
 intended as an offer or solicitation for the purchase or sale of 
 any financial instrument or as an official confirmation of any 
 transaction, unless specifically agreed otherwise.  All market 
 prices, data and other information are not warranted as to 
 completeness or accuracy and are subject to change without
 notice.  Any comments or statements made herein do not 
 necessarily reflect the views or opinions of Capital Institutional
 Services, Inc.  Capital Institutional Services, Inc. accepts no
 liability for any errors or omissions arising as a result of
 transmission.  Use of this communication by other than intended
 recipients is prohibited.
 **
 
 -- 
 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]




RE: [PHP] Array Problem

2001-05-22 Thread Matt Schroebel


 What is the best way to delete an element from an array?
 I tried using unset(), and it didn't work.

unset works with arrary elements, but it must be a global variable and not passed in.  
Try the code below to see the results.

?php
// deletes an element of global array
function deleteGlobal() {
global $animals;
echo brin deleteGlobal()-Spotbr\n;
unset ($animals[Spot]);
foreach ($animals as $key = $value) {
echo $key: $valuebr\n;
}
}
// deletes an element in local array only
function deleteElement($annArr) {
echo brin deleteElement()-Felixbr\n;
unset ($annArr[Felix]);
foreach ($annArr as $key = $value) {
echo $key: $valuebr\n;
}
}
// 
$animals = array(Kitty=cat, Max=dog, Spot=Dog, 
Felix=cat,Morris=cat);
echo Initial arraybr\n;
foreach ($animals as $key = $value) {
echo $key: $valuebr\n;
}
deleteGlobal();
echo brafter deleteGlobal()br\n;
foreach ($animals as $key = $value) {
echo $key: $valuebr\n;
}
deleteElement($animals);
echo brafter deleteElement()br\n;
foreach ($animals as $key = $value) {
echo $key: $valuebr\n;
}
echo brAfter unset()-Morrisbr\n;
unset ($animals[Morris]);
foreach ($animals as $key = $value) {
echo $key: $valuebr\n;
}
?

-- 
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] Array problem

2001-04-06 Thread Mark Roedel

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 06, 2001 3:20 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Array problem
 
 
 I am having big problems with merging two arrays. I just 
 can't seem to get my head around it.
 
 I have two arrays which I wish to merge, but I want to 
 EXCLUDE duplicate values.
 
 Any suggestions, as my numerous attempts have proved
 unsuccessful.

I expect my approach would probably be to merge the two arrays together,
then call array_unique() on the result.


---
Mark Roedel ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
 LeTourneau University  ||-- Henry Kissinger


--
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] Array problem

2001-04-06 Thread Joe Stump

This would work ...

?

  $arrA = array(1,2,3,4,5,6);
  $arrB = array(9,8,7,6,5);

  // pick an arbitrary one to start with ...
  for($i = 0 ; $i = sizeof($arrB) ; ++$i)
if(!in_array($arrB[$i],$arrA))
  $arrA[] = $arrB[$i];

?


--Joe


On Fri, Apr 06, 2001 at 09:19:52AM +0100, Alexis Antonakis wrote:
 Hi,
 
 I am having big problems with merging two arrays. I just can't seem to get
 my head around it.
 
 I have two arrays which I wish to merge, but I want to EXCLUDE duplicate
 values.
 
 Any suggestions, as my numerous attempts have proved unsuccessful.
 
 BTW I'm using PHP4.
 
 Many thanks
 Alexis
 
 
 -- 
 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]


/**\
 *Joe Stump - PHP/SQL/HTML Developer  *
 * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
 * "Better to double your money on mediocrity than lose it all on a dream."   * 
\**/

-- 
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]