RE: [PHP] Array help.

2012-10-24 Thread Ford, Mike
> From: Paul Halliday [paul.halli...@gmail.com] > Sent: 24 October 2012 18:38 > To: PHP-General > Subject: [PHP] Array help. > > $groupMappings = array('40' =>'A','41' =>'B','1' =>'C'); > > $ocTest = explode(".", $ip); > $groupKeys = array_keys($groupMappings); > $groupTest = arra

Re: [PHP] Array help.

2012-10-24 Thread Paul Halliday
On Wed, Oct 24, 2012 at 2:40 PM, Samuel Lopes Grigolato wrote: > Could you try changing this: > > if($groupTest != FALSE) { > > to this: > > if($groupTest !== FALSE) { > > ? Hah. Perfect! Thanks. > > -Mensagem original- > De: Paul Halliday [mailto:paul.halli...@gmail.com] > Enviada em: q

Re: [PHP] Array & unset()

2012-09-24 Thread Ashley Sheridan
Ken Robinson wrote: >At 08:50 PM 9/23/2012, Ron Piggott wrote: > >>I am wondering if there is a way to remove from >>an array where the value is 0 (“zero”) >> >>Array example: >> >>$total_points_awarded = array( 1 => 17, 3 => 14, 4 => 0, 5 => 1, 6 => >0 ); >> >>In this example I would like

Re: [PHP] Array & unset()

2012-09-23 Thread Ken Robinson
At 08:50 PM 9/23/2012, Ron Piggott wrote: I am wondering if there is a way to remove from an array where the value is 0 (“zero”) Array example: $total_points_awarded = array( 1 => 17, 3 => 14, 4 => 0, 5 => 1, 6 => 0 ); In this example I would like to remove element # 4 and # 6. The “

Re: [PHP] array

2011-12-31 Thread Govinda
>> how can you explain someone in a simplest and everyday use example of ARRAY. > > The manual page explains it pretty succinctly. I don't think you'll get > more simple than this, as there is obvious prerequisite knowledge > assumed (i.e. that you know what a simple variable is, etc) Hi saeed,

Re: [PHP] array

2011-12-31 Thread Ashley Sheridan
On Sat, 2011-12-31 at 14:53 +0100, saeed ahmed wrote: > how can you explain someone in a simplest and everyday use example of ARRAY. > The manual page explains it pretty succinctly. I don't think you'll get more simple than this, as there is obvious prerequisite knowledge assumed (i.e. that you

Re: [PHP] Array has `trailing comma`, why not the same for function parameter list?

2011-10-31 Thread Daniel Brown
On Sun, Oct 30, 2011 at 08:47, Nam Gi VU wrote: > It is convenient to have a trailing comma when defining an array - so as > easy to add/remove code to add/remove an entry to the array > > array( >    'key00' => 'value00', >    'key01' => 'value01', >    'key02' => 'value02', >    ... > ) > > I su

Re: [PHP] Array has `trailing comma`, why not the same for function parameter list?

2011-10-30 Thread Jeremiah Dodds
On Sun, Oct 30, 2011 at 8:47 AM, Nam Gi VU wrote: > It is convenient to have a trailing comma when defining an array - so as > easy to add/remove code to add/remove an entry to the array > > array( >    'key00' => 'value00', >    'key01' => 'value01', >    'key02' => 'value02', >    ... > ) > > I

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 wrote: I am reading a csv file into an array. The csv fil

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 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"); >

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 wrote: > I am reading a csv file into an array. The csv file. > > users.csv file contents: > w12345678,a > w23456789,b > w34567890,c > >

Re: [PHP] Array from one form to other?

2011-02-20 Thread Tamara Temple
On Feb 20, 2011, at 10:51 AM, Yogesh wrote: I don't entirely understand this; Dan Brown gave you solution to use curl to pass the array to the second "form" (do you mean script here?). That would certainly work, but I'm wondering if it wouldn't be more secure to spool out the array to a fi

Re: [PHP] Array from one form to other?

2011-02-20 Thread Yogesh
Hi Tamara, I don't entirely understand this; Dan Brown gave you solution to use curl to >> pass the array to the second "form" (do you mean script here?). That would >> certainly work, but I'm wondering if it wouldn't be more secure to spool out >> the array to a file from the first script after

Re: [PHP] Array from one form to other?

2011-02-20 Thread Tamara Temple
On Feb 19, 2011, at 6:38 PM, Yogesh wrote: I have two forms. One form helps read an input file into an array. And the other form needs this array as an input. I am able to read the input file into an array, but how do I pass it over to the other form. Both forms have PHP file as 'action'.

Re: [PHP] Array from one form to other?

2011-02-19 Thread Daniel Brown
On Sat, Feb 19, 2011 at 21:50, Yogesh wrote: > POST Use cURL, look into curl_setopt(), and add square brackets (and optional key names) to your array. A quick start: -- Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http:

Re: [PHP] Array from one form to other?

2011-02-19 Thread Yogesh
POST On Sat, Feb 19, 2011 at 9:44 PM, Daniel Brown wrote: > On Sat, Feb 19, 2011 at 19:38, Yogesh wrote: > > Hello, > > > > I have two forms. One form helps read an input file into an array. And > the > > other form needs this array as an input. > > I am able to read the input file into an

Re: [PHP] Array from one form to other?

2011-02-19 Thread Daniel Brown
On Sat, Feb 19, 2011 at 19:38, Yogesh wrote: > Hello, > > I have two forms. One form helps read an input file into an array. And the > other form needs this array as an input. > I am able to read the input file into an array, but how do I pass it over to > the other form. > > Both forms have PHP f

Re: [PHP] array to var - with different name

2011-01-21 Thread Donovan Brooke
Donovan Brooke wrote: [snip] if ($t_ok) { } Small correction.. with my established naming convention.. the above ideally would be: > if ($b_ok) { > > } D -- D Brooke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] array to var - with different name

2011-01-21 Thread Donovan Brooke
Paul M Foster wrote: [snip] Shawn, I don't know if I have a good reason, other than I rather like working with string vars instead of array vars from $_REQUEST for (sticky forms and conditionals). I can check/verify them as well in the process. You should probably get used to dealing with the a

Re: [PHP] array to var - with different name

2011-01-20 Thread Paul M Foster
On Thu, Jan 20, 2011 at 05:29:01PM -0600, Donovan Brooke wrote: [snip] > > > Shawn, I don't know if I have a good reason, other than I rather like > working with string vars instead of array vars from $_REQUEST for > (sticky forms and conditionals). I can check/verify them as well in the > pro

RE: [PHP] array to var - with different name

2011-01-20 Thread Tommy Pham
> -Original Message- > From: Donovan Brooke [mailto:li...@euca.us] > Sent: Thursday, January 20, 2011 3:29 PM > Cc: php-general@lists.php.net > Subject: Re: [PHP] array to var - with different name > > Tommy Pham wrote: > [snip] > >> foreach ($_REQUEST a

Re: [PHP] array to var - with different name

2011-01-20 Thread Donovan Brooke
Tommy Pham wrote: [snip] foreach ($_REQUEST as $key => $value) $$key = $value; short-circuited one-liners :) Regards, Tommy akk... wrong clicked before I had a chance to fix the code. anyway, foreach ($_GET as $key => $value) if (substr($key, 0, 2) == 'f_') ${'t_'.substr($key, 2)} = $valu

Re: [PHP] array to var - with different name

2011-01-20 Thread Tommy Pham
On Thu, Jan 20, 2011 at 3:09 PM, Tommy Pham wrote: > On Thu, Jan 20, 2011 at 2:28 PM, Donovan Brooke wrote: >> Hello again! >> >> I'm trying to find a good way to convert array key/value's to >> variable name values... but with the caveat of the name being >> slightly different than the original k

Re: [PHP] array to var - with different name

2011-01-20 Thread Tommy Pham
On Thu, Jan 20, 2011 at 2:28 PM, Donovan Brooke wrote: > Hello again! > > I'm trying to find a good way to convert array key/value's to > variable name values... but with the caveat of the name being > slightly different than the original key > (to fit my naming conventions). > > first, I (tediousl

Re: [PHP] array to var - with different name

2011-01-20 Thread Daniel Molina Wegener
On Thursday 20 January 2011, Donovan Brooke wrote: > Hello again! > > I'm trying to find a good way to convert array key/value's to > variable name values... but with the caveat of the name being > slightly different than the original key > (to fit my naming conventions). > > first, I (tediousl

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread David Harkness
On Thu, Jan 13, 2011 at 10:07 AM, David Hutto wrote: > On Thu, Jan 13, 2011 at 12:59 PM, David Harkness > > I learned it early on as well, and I never really liked it. Instead of > > $iFish I would prefer a more descriptive name such as $fishCount. > > What info did you get on hook for the client

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread David Hutto
On Thu, Jan 13, 2011 at 12:59 PM, David Harkness wrote: > On Thu, Jan 13, 2011 at 2:23 AM, Richard Quadling wrote: > >> The Hungarian Notation [1] was what I was taught all those years ago >> when I learnt standard C programming. > > > I learned it early on as well, and I never really liked it. In

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread David Harkness
On Thu, Jan 13, 2011 at 2:23 AM, Richard Quadling wrote: > The Hungarian Notation [1] was what I was taught all those years ago > when I learnt standard C programming. I learned it early on as well, and I never really liked it. Instead of $iFish I would prefer a more descriptive name such as $fi

Re: [PHP] Array Symbol Suggestion

2011-01-13 Thread Richard Quadling
On 12 January 2011 20:23, wrote: > Thanks for all the responses to my suggestion.  I realize this would be a > major change, so that's why I also mentioned it as an addition to the > language. > > I'm sure it's just what you're used to, but still being new to all this, it > just makes sense (t

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Per Jessen
Donovan Brooke wrote: > however, from my experience, there is often this kind of problem in > any language, and that is where naming conventions come in very handy. > > I don't know if the PHP community has any standard convention.. One popular naming convention: http://en.wikipedia.org/wiki/H

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Per Jessen
Ashley Sheridan wrote: > On Wed, 2011-01-12 at 12:23 -0800, sono...@fannullone.us wrote: > >> Thanks for all the responses to my suggestion. I realize this would >> be a major change, so that's why I also mentioned it as an addition >> to the language. >> >> I'm sure it's just what you're used

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Daniel Brown
On Wed, Jan 12, 2011 at 15:41, Michael Shadle wrote: > On Wed, Jan 12, 2011 at 12:37 PM, Daniel Brown wrote: > >>    The @ is an error control operator, used to buffer the output and >> store it in a variable - $php_errormsg.  There's no way that would be >> changed to become an array designator

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Michael Shadle
On Wed, Jan 12, 2011 at 12:37 PM, Daniel Brown wrote: >    The @ is an error control operator, used to buffer the output and > store it in a variable - $php_errormsg.  There's no way that would be > changed to become an array designator (though that doesn't mean your > idea itself is a bad one).

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Daniel Brown
On Wed, Jan 12, 2011 at 14:45, wrote: > I'd like to make a suggestion for a change, or possibly an addition, to the > PHP language. > > I'm learning PHP and have been very excited with what it can do in relation > to HTML.  But when I got to the part about arrays, I was disappointed to see > t

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Joshua Kehn
On Jan 12, 2011, at 3:28 PM, Ashley Sheridan wrote: > If you check out the manual pages for those functions as well, you'll > see other related functions. I must say, of any language I've used, the > php.net documentation is by far the best, giving plenty of information > and user comments too. It

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Joshua Kehn
On Jan 12, 2011, at 3:23 PM, sono...@fannullone.us wrote: > Thanks for all the responses to my suggestion. I realize this would be a > major change, so that's why I also mentioned it as an addition to the > language. > > I'm sure it's just what you're used to, but still being new to all this,

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Ashley Sheridan
On Wed, 2011-01-12 at 12:23 -0800, sono...@fannullone.us wrote: > Thanks for all the responses to my suggestion. I realize this would be a > major change, so that's why I also mentioned it as an addition to the > language. > > I'm sure it's just what you're used to, but still being new to all

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread sono-io
Thanks for all the responses to my suggestion. I realize this would be a major change, so that's why I also mentioned it as an addition to the language. I'm sure it's just what you're used to, but still being new to all this, it just makes sense (to me anyway) to have different symbols for diff

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Steve Staples
On Wed, 2011-01-12 at 20:58 +0100, Per Jessen wrote: > sono...@fannullone.us wrote: > > > I'd like to make a suggestion for a change, or possibly an addition, > > to the PHP language. > > > > I'm learning PHP and have been very excited with what it can do in > > relation to HTML. But when I got

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Ashley Sheridan
On Wed, 2011-01-12 at 11:45 -0800, sono...@fannullone.us wrote: > I'd like to make a suggestion for a change, or possibly an addition, to the > PHP language. > > I'm learning PHP and have been very excited with what it can do in relation > to HTML. But when I got to the part about arrays, I wa

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Donovan Brooke
sono...@fannullone.us wrote: I'd like to make a suggestion for a change, or possibly an addition, to the PHP language. I'm learning PHP and have been very excited with what it can do in relation to HTML. But when I got to the part about arrays, I was disappointed to see that they are designa

Re: [PHP] Array Symbol Suggestion

2011-01-12 Thread Per Jessen
sono...@fannullone.us wrote: > I'd like to make a suggestion for a change, or possibly an addition, > to the PHP language. > > I'm learning PHP and have been very excited with what it can do in > relation to HTML. But when I got to the part about arrays, I was > disappointed to see that they are

Re: [PHP] array question

2010-12-20 Thread Ravi Gehlot
Jim Lucas has it. You can use the preg_match function to find it. I would use regexp for that reason. regexp is good for making sure things are typed the way they need to (mostly used for). Ravi. On Sat, Dec 18, 2010 at 5:17 PM, Jim Lucas wrote: > On 12/17/2010 12:52 PM, Sorin Buturugeanu wrot

Re: [PHP] array question

2010-12-18 Thread Jim Lucas
On 12/17/2010 12:52 PM, Sorin Buturugeanu wrote: Hello all! I have a question regarding arrays and the way I can use a value. Let's say I have this string: $s = 'banana,apple,mellon,grape,nut,orange' I want to explode it, and get the third value. For this I would normally do: $a = explode(',

Re: [PHP] array question

2010-12-17 Thread Sorin Buturugeanu
Tanks for all of your responses! I guess a function is the way to go. I just have to see if the situation comes up enough times to justify the function approach. @Dan: I really enjoyed your disclaimer :D -- Sorin Buturugeanu www.soin.ro

Re: [PHP] array question

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 15:52, Sorin Buturugeanu wrote: > Hello all! > > I have a question regarding arrays and the way I can use a value. > > Let's say I have this string: > > $s = 'banana,apple,mellon,grape,nut,orange' > > I want to explode it, and get the third value. For this I would normally

RE: [PHP] array question

2010-12-17 Thread Jay Blanchard
[snip] I have a question regarding arrays and the way I can use a value. Let's say I have this string: $s = 'banana,apple,mellon,grape,nut,orange' I want to explode it, and get the third value. For this I would normally do: $a = explode(',', $s); echo $s[2]; That's all fine, but is there a way

RE: [PHP] Array problem

2010-10-28 Thread Bob McConnell
From: Richard Quadling > On 27 October 2010 22:15, Kevin Kinsey 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 e

Re: [PHP] Array problem

2010-10-28 Thread Richard Quadling
On 27 October 2010 22:15, Kevin Kinsey 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 >> browse

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

Re: [PHP] Array / form processing

2010-10-08 Thread Sebastian Detert
Ron Piggott schrieb: I am writing a custom shopping cart that eventually the "cart" will be uploaded to PayPal for payment. I need to be able to include the option that the purchase is a gift certificate. At present my "add to cart" function goes like this: === # Gift Certificate: 1 is a gif

Re: [PHP] Array / form processing

2010-10-07 Thread chris h
I don't know what the context is like, but you may be better off just using an entire form here with hidden fields. i.e. Without knowing what else is going on in your page, and how the request is being handled on the server, it's kind of hard to give exact advice. :) Chris H.

Re: [PHP] Array / form processing

2010-10-07 Thread Ron Piggott
Many thanks, Chris. I have one additional question about this shopping cart project. I need to make a submit button for the purpose of removing an item from the shopping cart. What I am struggling with is to find an effective method for passing the product serial number (auto_increment in the

Re: [PHP] Array / form processing

2010-10-07 Thread chris h
$_SESSION['life_coaching_order'][$product][$gift]['quantity'] = $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1; === ... === foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference => $value ) { === In this example $value would be an array. To test if it is

Re: [PHP] Array question

2010-09-26 Thread tedd
At 3:31 PM -0500 9/25/10, MikeB wrote: -snip- My question, in the loop, why does tha author use: $results[] = mysql_fetch_array($result); instead of (as I would expect): $results[$j] = mysql_fetch_array($result);? What PHP magic is at work here? Mike: That's just a shorthand way to popula

Re: [PHP] Array question

2010-09-26 Thread a...@ashleysheridan.co.uk
I'd also like to add to that: $array = array(); $array[] = 'text'; $array[2] = 123; $array[] = 'hello'; Would output: $array( 0 => 'text', 2 => 123, 3 => 'hello', ); Note the missing index 1, as php makes a numerical index that is one greater than the highest already in use. As the index 2 was

Re: [PHP] Array question

2010-09-25 Thread chris h
Mike, $results[] will automatically push a value unto the end of an array. So doing this... -- $magic = array(); $magic[] = 'a'; $magic[] = 'b'; $magic[] = 'c'; - is exactly this same as doing this... -- $normal = array(); $normal[0] = 'a'; $normal[1] = 'b'; $normal[2] = 'c'; -

Re: [PHP] Array help.

2010-07-30 Thread Joshua Kehn
On Jul 30, 2010, at 3:03 PM, Paul Halliday wrote: >> >> Paul- >> >> Why are those values not defaulted to 0 in the database? >> >> Regards, >> >> -Josh >> >> > > They are defaulted, the query is grouping: > > select count(status) as count, status from table group by status

Re: [PHP] Array help.

2010-07-30 Thread Paul Halliday
On Fri, Jul 30, 2010 at 3:44 PM, Joshua Kehn wrote: > > On Jul 30, 2010, at 2:36 PM, Paul Halliday wrote: > >> I have a query that may not always return a result for a value, I need >> to reflect this with a "0". I am trying to overcome this by doing this >> (the keys are ID's): >> >> while ($row

Re: [PHP] Array help.

2010-07-30 Thread Joshua Kehn
On Jul 30, 2010, at 2:36 PM, Paul Halliday wrote: > I have a query that may not always return a result for a value, I need > to reflect this with a "0". I am trying to overcome this by doing this > (the keys are ID's): > > while ($row = mysql_fetch_row($statusQuery)) { > >$cat = > arra

[PHP] Re: php array in different OS

2010-07-23 Thread Yang Fei
Dear Colin Guthrie , Thanks for your help very much. According to your suggestion, I have solved the question. best wish, Yang Fei 2010-7-24

[PHP] Re: php array in different OS

2010-07-23 Thread Colin Guthrie
'Twas brillig, and fyang at 22/07/10 03:34 did gyre and gimble: 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

Re: [PHP] Array form processing

2010-06-30 Thread tedd
At 4:54 PM -0400 6/29/10, Ron Piggott wrote: I am trying to process a form where the user uses checkboxes: Sharp Stabbing Jabbing When I do: foreach($_REQUEST as $key => $val) { $$key = $val; echo $key . ": " . $val . ""; } The output is: painDesc: Array I need to know the val

RE: [PHP] Array form processing

2010-06-30 Thread Ford, Mike
> -Original Message- > From: Ron Piggott [mailto:ron.pigg...@actsministries.org] > Sent: 29 June 2010 22:22 > > Am I on the right track? I don't know what to do with the second > "FOREACH" Sort of. > > > foreach($_REQUEST as $key => $val) { > $$key = $val; >echo $key . "

Re: [PHP] Array form processing

2010-06-29 Thread Jim Lucas
Ron Piggott wrote: > I am trying to process a form where the user uses checkboxes: > > Sharp > Stabbing > Jabbing > > When I do: > > foreach($_REQUEST as $key => $val) { > $$key = $val; >echo $key . ": " . $val . ""; > } > > The output is: > > painDesc: Array > > I need to know t

Re: [PHP] Array form processing

2010-06-29 Thread Ron Piggott
Am I on the right track? I don't know what to do with the second "FOREACH" $val) { $$key = $val; echo $key . ": " . $val . ""; if ( $val == "Array" ) { $i=0; foreach ($val) { echo "$val[$i]";

Re: [PHP] Array form processing

2010-06-29 Thread Shreyas Agasthya
The painDesc array is what that should be iterated. --Shreyas On Wed, Jun 30, 2010 at 2:27 AM, Ashley Sheridan wrote: > On Tue, 2010-06-29 at 16:54 -0400, Ron Piggott wrote: > > > I am trying to process a form where the user uses checkboxes: > > > > Sharp > > Stabbing > > Jabbing > > > > When I

Re: [PHP] Array form processing

2010-06-29 Thread Ashley Sheridan
On Tue, 2010-06-29 at 16:54 -0400, Ron Piggott wrote: > I am trying to process a form where the user uses checkboxes: > > Sharp > Stabbing > Jabbing > > When I do: > > foreach($_REQUEST as $key => $val) { > $$key = $val; >echo $key . ": " . $val . ""; > } > > The output is: > > p

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings
Paul M Foster wrote: On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which one is cor

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote: > On 8 June 2010 16:38, Ashley Sheridan wrote: > > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > > > >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: > >> > >> > Tanel Tammik wrote: > >> >> Hi, > >> >> > >>

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 17:11 +0200, Peter Lind wrote: > On 8 June 2010 16:53, Ashley Sheridan wrote: > > > > On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: > > > > On 8 June 2010 16:38, Ashley Sheridan wrote: > > > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > > > > > >> On Tue,

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:53, Ashley Sheridan wrote: > > On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: > > On 8 June 2010 16:38, Ashley Sheridan wrote: > > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > > > >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: > >> > >> >

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: > On 8 June 2010 16:38, Ashley Sheridan wrote: > > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > > > >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: > >> > >> > Tanel Tammik wrote: > >> >> Hi, > >> >> > >> >> whi

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:38, Ashley Sheridan wrote: > On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > >> On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: >> >> > Tanel Tammik wrote: >> >> Hi, >> >> >> >> which one is correct or "better"? >> >> >> >> $array[3] = ''; >> >> or >> >

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: > On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: > > > Tanel Tammik wrote: > >> Hi, > >> > >> which one is correct or "better"? > >> > >> $array[3] = ''; > >> or > >> $array['3'] = ''; > >> > >> $i = 7; > >> > >> $array[$i]

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: > Tanel Tammik wrote: >> Hi, >> >> which one is correct or "better"? >> >> $array[3] = ''; >> or >> $array['3'] = ''; >> >> $i = 7; >> >> $array[$i] = ''; >> or >> $array["$i"] = ''; > > Sometimes it is good to illustrate the correct

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 09:38 -0400, Robert Cummings wrote: > Tanel Tammik wrote: > > Hi, > > > > which one is correct or "better"? > > > > $array[3] = ''; > > or > > $array['3'] = ''; > > > > $i = 7; > > > > $array[$i] = ''; > > or > > $array["$i"] = ''; > > Sometimes it is good to illustrate

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings
Tanel Tammik wrote: Hi, which one is correct or "better"? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array["$i"] = ''; Sometimes it is good to illustrate the correct answer: '1', '2' => '2', 'three' => 'three', '4.0' => '4.0', 5.0 => 5.0, )

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:12 +0300, Tanel Tammik wrote: > Hi, > > which one is correct or "better"? > > $array[3] = ''; > or > $array['3'] = ''; > > $i = 7; > > $array[$i] = ''; > or > $array["$i"] = ''; > > > Br > Tanel > > > The two indexes are equivalent, although I reckon the intege

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:12:42PM +0300, Tanel Tammik wrote: > Hi, > > which one is correct or "better"? > > $array[3] = ''; > or > $array['3'] = ''; If the index for (integer) 3, the first example is correct. If the index is (string) '3', the second example is correct. > > $i = 7; > > $arr

Re: [PHP] Array group and sum values.

2010-05-11 Thread Shawn McKenzie
On 05/11/2010 04:09 PM, Shawn McKenzie wrote: > On 05/11/2010 02:17 PM, Paul Halliday wrote: >> On Tue, May 11, 2010 at 4:03 PM, Jim Lucas wrote: >>> Paul Halliday wrote: On Tue, May 11, 2010 at 2:25 PM, Jim Lucas wrote: > Paul Halliday wrote: >> I have this: >> >> while ($ro

Re: [PHP] Array group and sum values.

2010-05-11 Thread Shawn McKenzie
On 05/11/2010 02:17 PM, Paul Halliday wrote: > On Tue, May 11, 2010 at 4:03 PM, Jim Lucas wrote: >> Paul Halliday wrote: >>> On Tue, May 11, 2010 at 2:25 PM, Jim Lucas wrote: Paul Halliday wrote: > I have this: > > while ($row = mysql_fetch_array($theData[0])) { > > $

Re: [PHP] Array group and sum values.

2010-05-11 Thread Paul Halliday
On Tue, May 11, 2010 at 4:03 PM, Jim Lucas wrote: > Paul Halliday wrote: >> On Tue, May 11, 2010 at 2:25 PM, Jim Lucas wrote: >>> Paul Halliday wrote: I have this: while ($row = mysql_fetch_array($theData[0])) {     $col1[] = $row[0];     $col2[] = lookup($row[1]); /

Re: [PHP] Array group and sum values.

2010-05-11 Thread Jim Lucas
Paul Halliday wrote: > On Tue, May 11, 2010 at 2:25 PM, Jim Lucas wrote: >> Paul Halliday wrote: >>> I have this: >>> >>> while ($row = mysql_fetch_array($theData[0])) { >>> >>> $col1[] = $row[0]; >>> $col2[] = lookup($row[1]); // this goes off and gets the country name. >>> >>> I then loo

Re: [PHP] Array group and sum values.

2010-05-11 Thread Paul Halliday
On Tue, May 11, 2010 at 2:25 PM, Jim Lucas wrote: > Paul Halliday wrote: >> I have this: >> >> while ($row = mysql_fetch_array($theData[0])) { >> >>     $col1[] = $row[0]; >>     $col2[] = lookup($row[1]); // this goes off and gets the country name. >> >> I then loop through col1 and col2 to produ

Re: [PHP] Array group and sum values.

2010-05-11 Thread Jim Lucas
Paul Halliday wrote: > I have this: > > while ($row = mysql_fetch_array($theData[0])) { > > $col1[] = $row[0]; > $col2[] = lookup($row[1]); // this goes off and gets the country name. > > I then loop through col1 and col2 to produce something like this: > > 52ARMENIA > 215 CANADA

RE: [PHP] Array to csv or excel in php

2010-04-19 Thread Jay Blanchard
[snip] to export them on an csv or excel format[/snip] Stupid browser tricks http://www.evolt.org/node/26896 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Array to csv or excel in php

2010-04-19 Thread Ken Guest
For non-simple data I have been using PEAR's File_CSV package. It's proven itself very useful in regards to not having to determine in my own code whether something needs to be quoted etc etc - especially if the output CSV needs to be wholly RFC 4180 compliant. The documentation of it is rather mi

Re: [PHP] Array to csv or excel in php

2010-04-19 Thread Peter Lind
On 19 April 2010 17:40, Andrew Ballard wrote: > On Mon, Apr 19, 2010 at 11:14 AM, Peter Lind wrote: >> On 19 April 2010 17:00, Andrew Ballard wrote: >>> On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis   1. $save=split("[|;]",$listOfItems); and what i want i s after making some

Re: [PHP] Array to csv or excel in php

2010-04-19 Thread Andrew Ballard
On Mon, Apr 19, 2010 at 11:14 AM, Peter Lind wrote: > On 19 April 2010 17:00, Andrew Ballard wrote: >> On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis >>> 1. $save=split("[|;]",$listOfItems); >>> >>> and what i want i s after making some changes to the attributes on the array >>> above to ex

Re: [PHP] Array to csv or excel in php

2010-04-19 Thread Peter Lind
On 19 April 2010 17:00, Andrew Ballard wrote: > On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis > wrote: >> hallo there everyone.. >> i got an array from my database >> Help with Code >> Tags >> *PHP Synt

Re: [PHP] Array to csv or excel in php

2010-04-19 Thread Andrew Ballard
On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis wrote: > hallo there everyone.. > i got an array from my database > Help with Code > Tags > *PHP Syntax* (Toggle Plain > Text

RE: [PHP] Array differences

2010-04-14 Thread tedd
At 9:37 AM -0600 4/14/10, Ashley M. Kirchner wrote: No because that only does a one-way comparison. It only tells me what's missing from $array2. I need it from both arrays. That's why I'm comparing 1 versus 2, then 2 versus 1, and then doing a merge/unique on the result. -snip- $arra

RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
> -Original Message- > From: lala [mailto:l...@mail.theorb.net] > Sent: Wednesday, April 14, 2010 10:15 AM > To: Ashley M. Kirchner > Cc: php-general@lists.php.net > Subject: Re: [PHP] Array differences > > Ashley M. Kirchner wrote: > > > >

Re: [PHP] Array differences

2010-04-14 Thread lala
Ashley M. Kirchner wrote: $array1 = array(1, 2, 3, 4, 5, 6); $array2 = array(1, 3, 2, 8, 9); $diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $array1); $result = array_unique(array_merge($diff1, $diff2)); => (4, 5, 6, 8, 9)

RE: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
-Original Message- > From: Ryan Sun [mailto:ryansu...@gmail.com] > Sent: Wednesday, April 14, 2010 8:45 AM > To: a...@ashleysheridan.co.uk > Cc: Ashley M. Kirchner; php-general@lists.php.net > Subject: Re: [PHP] Array differences > > Maybe this one works? > array_dif

Re: [PHP] Array differences

2010-04-14 Thread Ryan Sun
Maybe this one works? array_diff(array_unique($array1 + $array2), array_intersect($array1, $array2)) On Wed, Apr 14, 2010 at 4:39 AM, Ashley Sheridan wrote: > On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: > >> I have the following scenario: >> >> >> >>      $array1 = array("12", "3

Re: [PHP] Array differences

2010-04-14 Thread Ashley M. Kirchner
On 4/14/2010 2:39 AM, Ashley Sheridan wrote: On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: $array1 = array("12", "34", "56", "78", "90"); $array2 = array("12", "23", "56", "78", "89"); $diff1 = array_diff($array1, $array2); $diff2 = array_diff($array2, $ar

Re: [PHP] Array differences

2010-04-14 Thread Rene Veerman
On Wed, Apr 14, 2010 at 12:03 PM, Nathan Rixham wrote: > Ashley Sheridan wrote: >> On Tue, 2010-04-13 at 23:01 -0600, Ashley M. Kirchner wrote: >>> >>> However what I really want is a two-way comparison.  I want elements that >>> don't exist in either to be returned: >>> >> >> >> I don't see any p

  1   2   3   4   5   6   7   8   9   10   >