[PHP] Simple Array Question...

2006-10-05 Thread Russell Jones
lets say I have an array... $myArray = array ( firstkey = first val, secondkey = second val ) Can I still call these by their numeric order? ie, echo $myArray[0] shoudl print out first val...

[PHP] Simple array question, array delete

2005-04-06 Thread Ryan A
Hey, I have a $data_recs array like this: 12 445 45655 4 343 etc when the user gives me a number, i have to check if its in the array and delete that entry...how do i do that? I have looked at the manual but have gotten confused with array pop,splice,array_key_exists etc Thanks, Ryan --

Re: [PHP] Simple array question, array delete

2005-04-06 Thread Josip Dzolonga
Ryan A wrote: Hey, I have a $data_recs array like this: 12 445 45655 4 343 etc when the user gives me a number, i have to check if its in the array and delete that entry...how do i do that? I have looked at the manual but have gotten confused with array pop,splice,array_key_exists etc Thanks,

Re: [PHP] Simple array question, array delete

2005-04-06 Thread Ken
On Apr 6, 2005 3:09 PM, Ryan A [EMAIL PROTECTED] wrote: Hey, I have a $data_recs array like this: 12 445 45655 4 343 etc when the user gives me a number, i have to check if its in the array and delete that entry...how do i do that? I have looked at the manual but have gotten

Re: [PHP] Simple array question, array delete

2005-04-06 Thread Ken
On Apr 6, 2005 3:27 PM, Ken [EMAIL PROTECTED] wrote: On Apr 6, 2005 3:09 PM, Ryan A [EMAIL PROTECTED] wrote: Hey, I have a $data_recs array like this: 12 445 45655 4 343 etc when the user gives me a number, i have to check if its in the array and delete that

[PHP] Simple array question, part 2

2005-04-06 Thread Ryan A
Hey, I have a $data array like this: [0] = 158 [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 then when i delete the first one ([0] = 158) it becomes like this: [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 how do I get it to sort again from 0,1,2,3

RE: [PHP] Simple array question, part 2

2005-04-06 Thread Jay Blanchard
[snip] I have a $data array like this: [0] = 158 [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 then when i delete the first one ([0] = 158) it becomes like this: [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 how do I get it to sort again from

Re: [PHP] Simple array question, part 2

2005-04-06 Thread Josip Dzolonga
Ryan A wrote: what function should i lookup/use? Thanks, Ryan This will do the job : $array = array_values($array); Hope this helps, -- Josip Dzolonga http://josip.dotgeek.org jdzolonga[at]gmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Simple array question, part 2

2005-04-06 Thread Philip Hallstrom
Hey, I have a $data array like this: [0] = 158 [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 then when i delete the first one ([0] = 158) it becomes like this: [1] = 169926 [2] = 169931 [3] = 169932 [4] = 169933 how do I get it to sort again from 0,1,2,3 etc? I

RE: [PHP] Simple array question, part 2

2005-04-06 Thread Jay Blanchard
[snip] Nope, array_pop is just deleting the last key/valuei need to reindex it without deleteing anything. [/snip] Always reply to the list ('reply all') as the individual who answered you might not be there. Always. I mean it. You shouldn't just delete an item from an array, it is improper

Re: [PHP] Simple array question, part 2

2005-04-06 Thread Ryan A
PERFECT! Thanks mate. -Ryan On 8/6/2005 6:47:22 PM, Josip Dzolonga ([EMAIL PROTECTED]) wrote: Ryan A wrote: what function should i lookup/use? Thanks, Ryan This will do the job : $array = array_values($array); Hope this helps, -- Josip Dzolonga

Re: [PHP] Simple array question, part 2

2005-04-06 Thread Brent Baisley
Just so you know what is happening, the numbers are keys (index) for each array element, not the order number. It's the same as if you had named the elements themselves. Like this: ['zero']=158 ['one']=169926 ['two']=169931 ... Or [0]=158 [12]=169926 [5]=169931 ... Deleting an element won't

RE: [PHP] Simple array question, part 2

2005-04-06 Thread Ryan A
Nope, array_shift()... is taking off the last one too Josip sent me the solution: $array = array_values($array); Cheers, Ryan On 4/6/2005 6:45:40 PM, Jay Blanchard ([EMAIL PROTECTED]) wrote: [snip] Nope, array_pop is just deleting the last key/valuei need to reindex it without

Re: [PHP] Simple array question, array delete

2005-04-06 Thread Richard Lynch
On Wed, April 6, 2005 6:09 am, Ryan A said: when the user gives me a number, i have to check if its in the array and delete that entry...how do i do that? I have looked at the manual but have gotten confused with array pop,splice,array_key_exists etc http://php.net/array_search

Re: [PHP] Simple array question, array delete

2005-04-06 Thread Ryan A
On 4/7/2005 5:19:24 AM, [EMAIL PROTECTED] wrote: On Wed, April 6, 2005 6:09 am, Ryan A said: when the user gives me a number, i have to check if its in the array and delete that entry...how do i do that? I have looked at the manual but have gotten confused with array

[PHP] Simple array question

2003-10-22 Thread René Fournier
Is there a simple way to return the key (name) of one element in an array? I looked up key() in the docs, but there are no examples or notes... Thanks. ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Simple array question

2003-10-22 Thread Jason Wong
On Friday 24 October 2003 03:01, Ren Fournier wrote: Is there a simple way to return the key (name) of one element in an array? I looked up key() in the docs, but there are no examples or notes... array_search() -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software

Re: [PHP] Simple array question

2003-10-22 Thread David Otton
On Thu, 23 Oct 2003 14:01:59 -0500, you wrote: Is there a simple way to return the key (name) of one element in an array? I looked up key() in the docs, but there are no examples or notes... Ok, to make sure I understand you: given an array ('apple' = 'red', 'banana' = 'yellow') you want a

[PHP] Simple Array question

2003-07-29 Thread Ryan A
Hi, If i am posting something like this from a form: input type=checkbox name='id[sh1]' value=3 input type=checkbox name='id[sh2]' value=4 How do i get the value of id[]? eg: I dont want the sh1 and sh2, i just want the 3 and 4 The reason i dont wan the sh1 and sh2 is those are dynamic and

Re: [PHP] Simple Array question

2003-07-29 Thread Adam Voigt
I think what you want is: input type=checkbox name=id[] value=3 input type=checkbox name=id[] value=4 Then on your next page, you can just do: foreach($_POST['id'] AS $row) echo $row; Or whatever, and that way you only get what you need. On Tue, 2003-07-29 at 13:08, Ryan A wrote:

[PHP] simple array question

2002-05-27 Thread Jose Jeria
in javascript i can build an array doing like this: for(i=0; i whatEver.length; i++){ myArray[myArray.length] = // } What is the equivalent to this in PHP? Is this the only way: $myArray[count($myArray)] = //.. /J -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

Re: [PHP] simple array question

2002-05-27 Thread Billy S Halsey
Jose, Try this: for ($i = 0; $i $whatever; $i++) { $myArray[] = // ... } /bsh/ Jose Jeria wrote: in javascript i can build an array doing like this: for(i=0; i whatEver.length; i++){ myArray[myArray.length] = // } What is the equivalent to this in PHP? Is this the only

Re: [PHP] simple array question (Am a Newbie kindly excuse.)

2002-05-10 Thread Pekka Saarinen
Which gives out the output: Tesing arrays: ryan1, ryan1.2, ryan2, ryan2.1.1.1.1.1, ryan3, ryan3.2, my question/problem is simply this: how do i stop the last comma from coming? Hi, See http://www.php.net/manual/en/function.implode.php Pekka http://photography-on-the.net/ -- PHP General

[PHP] simple array question (Am a Newbie kindly excuse.)

2002-05-09 Thread r
Greetings my PHP people. Will do things a bit backwork code first and what i want as that seems the easiest way to explain Here is the code: ?php $a1[]=ryan1; $a1[]=ryan1.2; $a1[]=ryan2; $a1[]=ryan2.1.1.1.1.1; $a1[]=ryan3; $a1[]=ryan3.2; reset($a1); print(Tesing arrays:br);

RE: [PHP] simple array question (Am a Newbie kindly excuse.)

2002-05-09 Thread Matthew Walker
Software Engineer ePliant Marketing -Original Message- From: r [mailto:[EMAIL PROTECTED]] Sent: Friday, May 10, 2002 3:19 AM To: [EMAIL PROTECTED] Subject: [PHP] simple array question (Am a Newbie kindly excuse.) Greetings my PHP people. Will do things a bit backwork code first and what

Re: [PHP] simple array question (Am a Newbie kindly excuse.)

2002-05-09 Thread Miguel Cruz
echo join (',br', $a1); On Fri, 10 May 2002, r wrote: Here is the code: ?php $a1[]=ryan1; $a1[]=ryan1.2; $a1[]=ryan2; $a1[]=ryan2.1.1.1.1.1; $a1[]=ryan3; $a1[]=ryan3.2; reset($a1); print(Tesing arrays:br); while(list($aa1,$aa2) = each ($a1)) { print($aa2 . ,br); } ? Which