Re: [PHP] Array remove function?

2007-04-16 Thread Tijnema !
On 4/16/07, Jochem Maas <[EMAIL PROTECTED]> wrote: Richard Lynch wrote: > On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: >> [PS - I've the pleasure of listening to a colleague do a manual >> install >> of Vista over an existing copy of XP and then get the really tricky >> stuff >> like the so

Re: [PHP] Array remove function?

2007-04-16 Thread Jochem Maas
Richard Lynch wrote: > On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: >> [PS - I've the pleasure of listening to a colleague do a manual >> install >> of Vista over an existing copy of XP and then get the really tricky >> stuff >> like the soundcard to work ... for the last week :-/] > > Give

Re: [PHP] Array remove function?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 9:00 pm, Jochem Maas wrote: > [PS - I've the pleasure of listening to a colleague do a manual > install > of Vista over an existing copy of XP and then get the really tricky > stuff > like the soundcard to work ... for the last week :-/] Give them an Ubuntu (or similar) CD a

Re: [PHP] Array remove function?

2007-04-11 Thread Richard Lynch
On Wed, April 11, 2007 8:44 am, Tijnema ! wrote: > On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote: >> http://php.net/array_flip followed up an unset, followed by another >> array_flip, I guess... > > What if you have an array like this: > Array > ( > [0] => Array > ( >

Re: [PHP] Array remove function?

2007-04-11 Thread Jochem Maas
Paul Novitski wrote: > At 4/10/2007 03:09 PM, M.Sokolewicz wrote: >> Such a function is inherently a Bad Idea (tm). array-values are not >> unique. Array keys are. So unless you want to emulate the way >> array_flip works (bad idea (tm)), I'd say: leave it be. > > > Whoever owns that trademark ha

Re: [PHP] Array remove function?

2007-04-11 Thread Tijnema !
On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote: http://php.net/array_flip followed up an unset, followed by another array_flip, I guess... What if you have an array like this: Array ( [0] => Array ( [0] => 1 [1] => 2 [2] => 2 [3] => 2

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
On Tue, April 10, 2007 5:39 pm, Paul Novitski wrote: > values. If both keys and values are unique, I'd consider (if only > briefly) maintaining two arrays, one a flipped version of the other, > so I could look up key/value pairs using either node. I do this all the time for small/medium arrays.

Re: [PHP] Array remove function?

2007-04-10 Thread Paul Novitski
At 4/10/2007 03:09 PM, M.Sokolewicz wrote: Such a function is inherently a Bad Idea (tm). array-values are not unique. Array keys are. So unless you want to emulate the way array_flip works (bad idea (tm)), I'd say: leave it be. Whoever owns that trademark has totally got to be the wealthiest

Re: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Paul Novitski
At 4/10/2007 01:36 PM, Otto Wyss wrote: I've an array of file names $files = getFiles ($d); but would like to use this array in a JavaScript array. How can I copy this $files into a JavaScript variable? As I'm sure you know, you can't literally copy the values from PHP into the javascrip

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
On Tue, April 10, 2007 3:22 pm, Tijnema ! wrote: > On 4/10/07, Daevid Vincent <[EMAIL PROTECTED]> wrote: >> OMG. Now that is the best idea. How simple. Guess I learned >> something new >> today too! :) >> >> > -Original Message- >> > From: Lori Lay [mailto:[EMAIL PROTECTED] >> > >> > Use ar

Re: [PHP] Array remove function?

2007-04-10 Thread M.Sokolewicz
Lori Lay wrote: Tijnema ! wrote: On 4/10/07, Daevid Vincent <[EMAIL PROTECTED]> wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) > -Original Message- > From: Lori Lay [mailto:[EMAIL PROTECTED] > > Use array_search() and unset()? Interest

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
http://php.net/array_flip followed up an unset, followed by another array_flip, I guess... Why in the world you'd architect the array with a value when you need to unset by value in the first place is beyond me, though... On Tue, April 10, 2007 2:52 pm, Tijnema ! wrote: > On 4/10/07, Richard Lync

RE: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Peter Lauri
: Tuesday, April 10, 2007 10:37 PM > To: php-general@lists.php.net > Subject: [PHP] Copying PHP array into a Javascript array > > I don't know if I should ask this question here or in the JavaScript > group. I'll try it here since people usually are more helpful. > > I&

Re: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Otto Wyss
Jochem Maas wrote: // if you have this available: http://php.net/manual/en/function.json-encode.php echo json_encode($files); I thought there might be a solution with Json but couldn't locate it. I prefer it versus the iteration, thanks. Sometimes solutions are so simple if one knows them. O

Re: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Jochem Maas
Otto Wyss wrote: > I don't know if I should ask this question here or in the JavaScript > group. I'll try it here since people usually are more helpful. > > I've an array of file names > > $files = getFiles ($d); > > but would like to use this array in a JavaScript array. How can I copy > this

RE: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Buesching, Logan J
} ?> Although it looks nasty, I believe it could be a quick hack. -Original Message- From: Otto Wyss [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 10, 2007 4:37 PM To: php-general@lists.php.net Subject: [PHP] Copying PHP array into a Javascript array I don't kno

[PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Otto Wyss
I don't know if I should ask this question here or in the JavaScript group. I'll try it here since people usually are more helpful. I've an array of file names $files = getFiles ($d); but would like to use this array in a JavaScript array. How can I copy this $files into a JavaScript variab

Re: [PHP] Array remove function?

2007-04-10 Thread Lori Lay
Tijnema ! wrote: On 4/10/07, Daevid Vincent <[EMAIL PROTECTED]> wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) > -Original Message- > From: Lori Lay [mailto:[EMAIL PROTECTED] > > Use array_search() and unset()? Interesting, I didn't tho

Re: [PHP] Array remove function?

2007-04-10 Thread Tijnema !
On 4/10/07, Daevid Vincent <[EMAIL PROTECTED]> wrote: OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) > -Original Message- > From: Lori Lay [mailto:[EMAIL PROTECTED] > > Use array_search() and unset()? Interesting, I didn't thought of that :) Bu

Re: [PHP] Array remove function?

2007-04-10 Thread tg-php
Unset works, but if he's trying to do a search and remove in one function, unset is a step removed from that criteria (missing the 'search' part). Looking at the array functions, I see some potential. # array_remove(array(1=>2,2=>3),2,true); // array (2=>3) // Keep all but where values = 2 $new_

RE: [PHP] Array remove function?

2007-04-10 Thread Daevid Vincent
OMG. Now that is the best idea. How simple. Guess I learned something new today too! :) > -Original Message- > From: Lori Lay [mailto:[EMAIL PROTECTED] > > Use array_search() and unset()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub

Re: [PHP] Array remove function?

2007-04-10 Thread Lori Lay
Tijnema ! wrote: On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value? Tijnema Use array_search() and unset()? Lori On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: > Hi, > > Is there

RE: [PHP] Array remove function?

2007-04-10 Thread Buesching, Logan J
rom: Tijnema ! [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 10, 2007 3:53 PM To: [EMAIL PROTECTED] Cc: PHP Subject: Re: [PHP] Array remove function? On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote: > http://php.net/unset That works when you know the key, but will that work when you only kn

RE: [PHP] Array remove function?

2007-04-10 Thread Daevid Vincent
While that is true, you need to know the key, you could do something like this, which I think is more efficient than your way... foreach($array as $key => $value) { if ($value == $remove) { unset($array[$key]); //if you know there is only one hit,

Re: [PHP] Array remove function?

2007-04-10 Thread Tijnema !
On 4/10/07, Richard Lynch <[EMAIL PROTECTED]> wrote: http://php.net/unset That works when you know the key, but will that work when you only know the value? Tijnema On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: > Hi, > > Is there currently a function that removes a key/value from an arra

Re: [PHP] Array remove function?

2007-04-10 Thread Richard Lynch
http://php.net/unset On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote: > Hi, > > Is there currently a function that removes a key/value from an array? > I use this code right now: > function array_remove($array,$remove,$remove_value = true) > { > foreach($array as $key => $value) { >

[PHP] Array remove function?

2007-04-10 Thread Tijnema !
Hi, Is there currently a function that removes a key/value from an array? I use this code right now: function array_remove($array,$remove,$remove_value = true) { foreach($array as $key => $value) { if($remove_value && $value != $remove) { $new_array

Re: [PHP] Array Question

2007-03-25 Thread Stut
[EMAIL PROTECTED] wrote: $count=count($data->legs->leg); $k=0; while($k < $count) { $legrow["$data->legs->leg[$k]['legId']"]=$data->legs->leg[$k]['depApt'].$VM.$data->legs->leg[$k]['depTime'].$VM.$data->legs->leg[$k]['dstApt'].$VM.$data->legs->leg[$k

RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
MAIL PROTECTED] > Sent: Sunday, March 25, 2007 12:09 AM > To: Jake McHenry > Cc: php-general@lists.php.net > Subject: RE: [PHP] Array Question > > Hi Jake > > I am getting nothing at all. > > Regards > > Richard > > > What is the result your get

RE: [PHP] Array Question

2007-03-24 Thread rluckhurst
> Cc: php-general@lists.php.net >> Subject: RE: [PHP] Array Question >> >> Hi Jake >> >> I tried that and got the same result. >> >> Regards >> >> Richard >> >> > What if you put $temp = $data->legs-&

RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
What is the result your getting? Jake > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Saturday, March 24, 2007 11:57 PM > To: Jake McHenry > Cc: php-general@lists.php.net > Subject: RE: [PHP] Array Question > > Hi Jake >

RE: [PHP] Array Question

2007-03-24 Thread rluckhurst
gt; From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> Sent: Saturday, March 24, 2007 11:27 PM >> To: php-general@lists.php.net >> Subject: [PHP] Array Question >> >> Hi All >> >> I am having a bit of trouble with PHP arrays and would >> appreciate so

RE: [PHP] Array Question

2007-03-24 Thread rluckhurst
gt; $legrow["$data->legs->leg[$k]['legId']"] > > ?? See if that works... > > Jake > > > >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] >> Sent: Saturday, March 24, 2007 11:27 PM >> To: php-gener

RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
o: php-general@lists.php.net > Subject: [PHP] Array Question > > Hi All > > I am having a bit of trouble with PHP arrays and would > appreciate some help. > > I currently have the following piece of code > > $count=count($data->legs->leg); > $k=0; >

RE: [PHP] Array Question

2007-03-24 Thread Jake McHenry
$legrow["$data->legs->leg[$k]['legId']"] ?? See if that works... Jake > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Saturday, March 24, 2007 11:27 PM > To: php-general@lists.php.net > Subject: [PHP] Array Qu

[PHP] Array Question

2007-03-24 Thread rluckhurst
Hi All I am having a bit of trouble with PHP arrays and would appreciate some help. I currently have the following piece of code $count=count($data->legs->leg); $k=0; while($k < $count) { $legrow[$k]=$data->legs->leg[$k]['legId'].$VM.$data->

Re: [PHP] Array mysteries

2007-03-12 Thread Richard Lynch
On Sun, March 11, 2007 2:57 pm, Edward Vermillion wrote: > Would the array lookup be faster for a lesser-used option/key in a > situation where there were quite a few options? (you wouldn't have to > go through the whole switch to get to the option at the end (?) or > would you? I have no idea how

Re: [PHP] Array mysteries

2007-03-12 Thread Richard Lynch
On Sun, March 11, 2007 12:02 pm, Edward Vermillion wrote: > > On Mar 11, 2007, at 10:02 AM, tedd wrote: > >> At 3:05 PM +0100 3/11/07, Tijnema ! wrote: >>> On 3/11/07, tedd <[EMAIL PROTECTED]> >>> wrote: >>> >>> At 10:05 AM +0100 3/11/07, Tijnema ! wrote: - You c

Re: [PHP] Array mysteries

2007-03-12 Thread Richard Lynch
Read the manual again, especially the part about "variable scope" near the beginning. On Sun, March 11, 2007 3:51 am, Otto Wyss wrote: > I want to convert weekdays with a simple function like > >$wdays = array > (0 => "Sonntag" > ,1 => "Montag" > ,2 => "Dienstag" > ,3 =>

Re: [PHP] Array mysteries

2007-03-11 Thread Robert Cummings
On Sun, 2007-03-11 at 21:41 +0100, Satyam wrote: > - Original Message - > From: "Edward Vermillion" <[EMAIL PROTECTED]> > To: "tedd" <[EMAIL PROTECTED]> > Cc: "Tijnema !" <[EMAIL PROTECTED]>; > Sent: Sunday, March 11, 2007 8:

Re: [PHP] Array mysteries

2007-03-11 Thread Tijnema !
On 3/11/07, Satyam <[EMAIL PROTECTED]> wrote: - Original Message - From: "Edward Vermillion" <[EMAIL PROTECTED]> To: "tedd" <[EMAIL PROTECTED]> Cc: "Tijnema !" <[EMAIL PROTECTED]>; Sent: Sunday, March 11, 2007 8:57 PM Subject: Re

Re: [PHP] Array mysteries

2007-03-11 Thread Satyam
- Original Message - From: "Edward Vermillion" <[EMAIL PROTECTED]> To: "tedd" <[EMAIL PROTECTED]> Cc: "Tijnema !" <[EMAIL PROTECTED]>; Sent: Sunday, March 11, 2007 8:57 PM Subject: Re: [PHP] Array mysteries On Mar 11, 2007, at

Re: [PHP] Array mysteries

2007-03-11 Thread Edward Vermillion
On Mar 11, 2007, at 1:59 PM, tedd wrote: At 12:02 PM -0500 3/11/07, Edward Vermillion wrote: On Mar 11, 2007, at 10:02 AM, tedd wrote: At 3:05 PM +0100 3/11/07, Tijnema ! wrote: On 3/11/07, tedd <[EMAIL PROTECTED]> wrote: At 10:05 AM +0100 3/11/07, Tijnema ! wro

Re: [PHP] Array mysteries

2007-03-11 Thread tedd
At 12:02 PM -0500 3/11/07, Edward Vermillion wrote: On Mar 11, 2007, at 10:02 AM, tedd wrote: At 3:05 PM +0100 3/11/07, Tijnema ! wrote: On 3/11/07, tedd <[EMAIL PROTECTED]> wrote: At 10:05 AM +0100 3/11/07, Tijnema ! wrote: - You could define $wdays inside the fun

Re: [PHP] Array mysteries

2007-03-11 Thread Larry Garfield
On Sunday 11 March 2007 12:02 pm, Edward Vermillion wrote: > >> At 10:05 AM +0100 3/11/07, Tijnema ! wrote: > >>> - You could define $wdays inside the function > >>> function convert_from_weekday ($weekday) { > >>> $wdays = array > >>>(0 => "Sonntag" > >>>,1 => "Montag" > >>>,2 => "Dien

Re: [PHP] Array mysteries

2007-03-11 Thread Edward Vermillion
On Mar 11, 2007, at 10:02 AM, tedd wrote: At 3:05 PM +0100 3/11/07, Tijnema ! wrote: On 3/11/07, tedd <[EMAIL PROTECTED]> wrote: At 10:05 AM +0100 3/11/07, Tijnema ! wrote: - You could define $wdays inside the function function convert_from_weekday ($weekday) { $wd

Re: [PHP] Array mysteries

2007-03-11 Thread tedd
At 3:05 PM +0100 3/11/07, Tijnema ! wrote: On 3/11/07, tedd <[EMAIL PROTECTED]> wrote: At 10:05 AM +0100 3/11/07, Tijnema ! wrote: - You could define $wdays inside the function function convert_from_weekday ($weekday) { $wdays = array (0 => "Sonntag" ,1 => "Mont

Re: [PHP] Array mysteries

2007-03-11 Thread Tijnema !
On 3/11/07, tedd <[EMAIL PROTECTED]> wrote: At 10:05 AM +0100 3/11/07, Tijnema ! wrote: > >- You could define $wdays inside the function >function convert_from_weekday ($weekday) { >$wdays = array >(0 => "Sonntag" >,1 => "Montag" >,2 => "Dienstag" >,3 => "Mittwoch" >,4 => "Do

Re: [PHP] Array mysteries

2007-03-11 Thread tedd
At 10:05 AM +0100 3/11/07, Tijnema ! wrote: - You could define $wdays inside the function function convert_from_weekday ($weekday,$wdays) { $wdays = array (0 => "Sonntag" ,1 => "Montag" ,2 => "Dienstag" ,3 => "Mittwoch" ,4 => "Donnerstag" ,5 => "Freitag" ,6 => "Samstag" );

Re: [PHP] Array mysteries

2007-03-11 Thread Otto Wyss
Steve Edberg wrote: At 9:51 AM +0100 3/11/07, Otto Wyss wrote: function convert_from_weekday ($weekday) { return $wdays[$weekday]; } If the above is your exact code, then the problem is one of scope; move the $wdays declaration inside your convert_from_weekday() function. I'm more

Re: [PHP] Array mysteries

2007-03-11 Thread Satyam
- Original Message - From: "Otto Wyss" <[EMAIL PROTECTED]> To: Sent: Sunday, March 11, 2007 11:14 AM Subject: Re: [PHP] Array mysteries Steve Edberg wrote: At 9:51 AM +0100 3/11/07, Otto Wyss wrote: function convert_from_weekday ($weekday) { return

Re: [PHP] Array mysteries

2007-03-11 Thread Steve Edberg
At 9:51 AM +0100 3/11/07, Otto Wyss wrote: I want to convert weekdays with a simple function like $wdays = array (0 => "Sonntag" ,1 => "Montag" ,2 => "Dienstag" ,3 => "Mittwoch" ,4 => "Donnerstag" ,5 => "Freitag" ,6 => "Samstag" ); function convert_from_weekday

Re: [PHP] Array mysteries

2007-03-11 Thread Tijnema !
On 3/11/07, Otto Wyss <[EMAIL PROTECTED]> wrote: I want to convert weekdays with a simple function like $wdays = array (0 => "Sonntag" ,1 => "Montag" ,2 => "Dienstag" ,3 => "Mittwoch" ,4 => "Donnerstag" ,5 => "Freitag" ,6 => "Samstag" ); function convert_from_

[PHP] Array mysteries

2007-03-11 Thread Otto Wyss
I want to convert weekdays with a simple function like $wdays = array (0 => "Sonntag" ,1 => "Montag" ,2 => "Dienstag" ,3 => "Mittwoch" ,4 => "Donnerstag" ,5 => "Freitag" ,6 => "Samstag" ); function convert_from_weekday ($weekday) { return $wdays[$weekday];

Re: [PHP] Array help

2007-03-04 Thread Ryan A
Hey! Thanks Stut, Tijnema. I'll test out the ideas you guys contributed to me.. after I finish a working copy will ask you guys to give it a look over ;) @Stut: The list is not in alphabetical order.. and 2, I have no idea of the size of the file (for the regex suggestion) but I am guessing it

Re: [PHP] Array help

2007-03-04 Thread Tijnema !
Well, you are using the file_get_contents function right now, what about a loop that reads the file line by line, checks if the user matches, and stops when found the right user? it's an all in one loop :) just like this: $found = false; $fp = fopen($file,"r"); while(!feof($fp) && $found == fals

Re: [PHP] Array help

2007-03-04 Thread Stut
Ryan A wrote: Will be making two versions, one with a DB and one to work with the file for the old school folks who dont want to convert their file and use "new fangled" databases... some people its easier to just not argue or try to convince... and however stupid someone's opinion is, they are

Re: [PHP] Array help

2007-03-04 Thread Ryan A
Hey Stut, Thanks for replying. Will be making two versions, one with a DB and one to work with the file for the old school folks who dont want to convert their file and use "new fangled" databases... some people its easier to just not argue or try to convince... and however stupid someone's opin

Re: [PHP] Array help

2007-03-04 Thread Stut
Ryan A wrote: I have a login/password file with these kind of values: user1:pass1 user2:pass2 cat:dog love:hate I have opened the file and put it into an array with this code: (thanks to richard lynch from this list for idea and code snippets) $file = file_get_contents('a.htpasswd'); preg_ma

[PHP] Array help

2007-03-04 Thread Ryan A
Hi! I have a login/password file with these kind of values: user1:pass1 user2:pass2 cat:dog love:hate I have opened the file and put it into an array with this code: (thanks to richard lynch from this list for idea and code snippets) $file = file_get_contents('a.htpasswd'); preg_match_all('/(

Re: [PHP] array issues

2007-02-27 Thread Jim Lucas
Richard Lynch wrote: Just add another array for each with $artist as the key. while ($artist, $vote, $email) = mysql_fetch_row($results)){ I think you ment while ( list($artist, $vote, $email) = mysql_fetch_row($results) ){ $votes[$artist] = $vote; $emails[$artist] = $email; } Although,

Re: [PHP] array issues

2007-02-27 Thread Richard Lynch
Just add another array for each with $artist as the key. while ($artist, $vote, $email) = mysql_fetch_row($results)){ $votes[$artist] = $vote; $emails[$artist] = $email; } Although, actually, there is probably some better ways to do what you are doing, but with only the query to look at, it

Re: [PHP] Array question

2007-02-27 Thread Gerry D
Mike, See entire function under topic "Array question - maybe UTF?"... I am trying to change accented characters to their equivalent without accents. And yes, the arrays look fine after var_dump()... Gerry On 2/27/07, Ford, Mike <[EMAIL PROTECTED]> wrote: On 27 February 2007 04:23, Gerry D w

RE: [PHP] Array question

2007-02-27 Thread Ford, Mike
On 27 February 2007 04:23, Gerry D wrote: > I have a question on how to retrieve the value that corresponds to a > key in an array. > > $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry'); > > $key = array_search($c, $fruit); > if ( $key === FALSE ) >

[PHP] Array question - maybe UTF?

2007-02-26 Thread Gerry D
Perhaps it's more a UTF8 issue that is going wrong for me. At first strtr() was not giving me the results I wanted, so I started tinkering. This is what I came up with... Still no satisfactory results. I think character support is rather lacking in php, or maybe I just don't have a clue? Gerry

Re: [PHP] Array question

2007-02-26 Thread Hap-Hang Yu
Try: $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry'); $search = 'apple'; foreach($fruit as $key => $val) { if ($val == $search) { echo "$search found: array key is $key, value is $val"; } } 2007/2/27, Gerry D <[EMAIL PROTECTED]>: I have a question on how to retrieve t

[PHP] Array question

2007-02-26 Thread Gerry D
I have a question on how to retrieve the value that corresponds to a key in an array. $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry'); $key = array_search($c, $fruit); if ( $key === FALSE ) $n = $c; else

Re: [PHP] array issues

2007-02-26 Thread Matt Carlson
If i'm understanding you correctly, you have something like a flat file, and hopefully it is artist[tab]artist[tab] with the title being something like artist1title[tab]artist2title[tab], etc. If so, use explode. $artists = explode("\t", $stringofartists); $songs = explode("\t", $stringoftitles

[PHP] array issues

2007-02-26 Thread Steven Macintyre
Hi all, I am working on a project for someone and with the brief I received before - I created a record per action with the following information; Artist[tab]artist[tab]artist[tab] etc as a entry for "artists" Then I have the same for titles etc ... What I have been doing is creating the array

Re: [PHP] Array to Object

2007-02-13 Thread Marc Weber
On Tue, Feb 13, 2007 at 12:02:10PM +0200, Eli wrote: > Hi, > > Having this array: > $arr = array( > 'my var'=>'My Value' > ); > Notice the space in 'my var'. > > Converted to object: > $obj = (object)$arr; > > How can I access $arr['my var'] in $obj ? This works but there ma

[PHP] Array to Object

2007-02-13 Thread Eli
Hi, Having this array: $arr = array( 'my var'=>'My Value' ); Notice the space in 'my var'. Converted to object: $obj = (object)$arr; How can I access $arr['my var'] in $obj ? -thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.p

Re: [PHP] array within array

2007-02-12 Thread Jim Lucas
rinted correctly - but my echoing of array items is not The stuff in bold SHOULD be on a new line ... Can you take a look and offer me more advice? S -Original Message- From: Jim Lucas [mailto:[EMAIL PROTECTED] Sent: 09 February 2007 09:56 AM To: Steven Macintyre Subject: Re: [PHP] arr

Re: [PHP] array within array

2007-02-09 Thread Németh Zoltán
On p, 2007-02-09 at 10:10 +0100, Németh Zoltán wrote: > On p, 2007-02-09 at 09:24 +0200, Steven Macintyre wrote: > > Hi all, > > > > I have an array ($articles) that contains content in this format > > > > Text > > More text > > > > I am currently calling the creation of the array as such; > >

Re: [PHP] array within array

2007-02-09 Thread Németh Zoltán
On p, 2007-02-09 at 09:24 +0200, Steven Macintyre wrote: > Hi all, > > I have an array ($articles) that contains content in this format > > Text > More text > > I am currently calling the creation of the array as such; > > $articles = split("Section break", $mystring); <-- this works > > NOW .

Re: [PHP] array within array

2007-02-08 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-02-09 09:24:01 +0200: > I am currently calling the creation of the array as such; > > $articles = split("Section break", $mystring); <-- this works > > NOW ... I need to split each item in the articles array into its own array > (newsarray) > > I have tried > > Forea

[PHP] array within array

2007-02-08 Thread Steven Macintyre
Hi all, I have an array ($articles) that contains content in this format Text More text I am currently calling the creation of the array as such; $articles = split("Section break", $mystring); <-- this works NOW ... I need to split each item in the articles array into its own array (newsarray)

Re: [PHP] Array decleration problem

2007-01-03 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2007-01-02 10:48:27 +0100: > Hi, > > I'm new to php and im learning, I haven't encounter any problems till > now so please help me? :) > > the code: (learning arrays...) > > > $flavors=array ("banana", "cucumber", "grape", "vanilla") that statement is incomp

[PHP] Array decleration problem

2007-01-03 Thread Delta Storm
Hi, I'm new to php and im learning, I haven't encounter any problems till now so please help me? :) the code: (learning arrays...) "; echo $flavors2; echo ""; echo $fruits; ?> I get an error message: Parse error: parse error, unexpected T_VARIABLE in C:\Progr

Re: [PHP] array, classes and values

2006-10-29 Thread Chris
martin wrote: hello, New to oop i'm really strugling to find a way to read a specified MYSQL database and tabel in order to determine the number of records, the number of fields in each record and convert the data into their labels and values. I suggest you search for "php mysql tutorial" in

[PHP] array, classes and values

2006-10-29 Thread martin
hello, New to oop i'm really strugling to find a way to read a specified MYSQL database and tabel in order to determine the number of records, the number of fields in each record and convert the data into their labels and values. Please give me some hints or code... Thanks, Martin -- PHP G

Re: [PHP] array size in bytes

2006-10-02 Thread Chris Boget
How about saving the array as a file and then do a filesize()? Wouldn't this work? $arraySize = strlen( implode( '', $array )); Though, additional work would need to be done for nested arrays. thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.

Re: [PHP] array size in bytes

2006-10-02 Thread tedd
At 4:18 PM -0500 10/2/06, Richard Lynch wrote: On Mon, October 2, 2006 3:07 am, Roman Rumisek wrote: Exists in PHP function returning array size in bytes ? (For saving array into shared memory without serialize.) No. And you could maybe write one, if it was all strings in the array, but you

Re: [PHP] array size in bytes

2006-10-02 Thread Richard Lynch
On Mon, October 2, 2006 3:07 am, Roman Rumisek wrote: > Exists in PHP function returning array size in bytes ? > (For saving array into shared memory without serialize.) No. And you could maybe write one, if it was all strings in the array, but you're gonna be screwed when PHP 6 with Unicode come

[PHP] array size in bytes

2006-10-02 Thread Roman Rumisek
Hi, Exists in PHP function returning array size in bytes ? (For saving array into shared memory without serialize.) Thnx. Roman -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] array problems

2006-08-16 Thread Richard Lynch
On Wed, August 16, 2006 1:08 am, Chris G wrote: > while($line = mysql_fetch_array($result)) { > > $data1y[] = $line['rep_value_perc']; $dataly[][] = $line['rep_value_prec']; > > } > > This gives me just the one array from the above example, $datay1. How > would > > you dynamically create the all

Re: [PHP] array problems

2006-08-16 Thread John Wells
On 8/16/06, David Tulloh <[EMAIL PROTECTED]> wrote: Chris G wrote: foreach ($user_input_array as $user_input) { $data_member = array(); # Create an empty array Do SQL query stuff foreach ($sql_results as $sql_member) { $data_member[] = $sql_member;

Re: [PHP] array problems

2006-08-16 Thread David Tulloh
Chris G wrote: > Hi all > > Having a prob with a php script... > > 3 arrays > > $datay1=array(140,110,50,60); > > $datay2=array(35,90,190,190); > > $datay3=array(20,60,70,140); > > which have to be passed to a class like this > > $gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));

[PHP] array problems

2006-08-15 Thread Chris G
Hi all Having a prob with a php script... 3 arrays $datay1=array(140,110,50,60); $datay2=array(35,90,190,190); $datay3=array(20,60,70,140); which have to be passed to a class like this $gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3)); if I get data from a database, how can I au

Re: [PHP] Array to String

2006-06-28 Thread Jochem Maas
Richard Lynch wrote: > On Mon, June 26, 2006 2:06 am, Jochem Maas wrote: >>> if (!get_magic_quotes_gpc()) { >>> if (isset($_POST)) { >>> foreach ($_POST as $key => $value) { >>> $_POST[$key] = trim(addslashes($value)); >>> } >>> } >>> >>> if (isset($_GET))

Re: [PHP] Array to String

2006-06-27 Thread Richard Lynch
On Mon, June 26, 2006 2:06 am, Jochem Maas wrote: >> if (!get_magic_quotes_gpc()) { >> if (isset($_POST)) { >> foreach ($_POST as $key => $value) { >> $_POST[$key] = trim(addslashes($value)); >> } >> } >> >> if (isset($_GET)) { >> foreach ($_GET as

Re: [PHP] Array to String

2006-06-26 Thread Jochem Maas
weetat wrote: > Hi all, > > I have the error below in my PHP version 4.3.2: > > PHP Notice: Array to string conversion in /data/html/library/config.php > on line 45 > > If i have turned "on" the magic_quotes in php.ini, it is ok . > Any ideas? > > It cause by the code below: > > if (!get_ma

Re: [PHP] Array to String

2006-06-25 Thread Chris
You are probably passing some variables into POST or GET using the array notation: /mypage.php?var[]=fred&var[]=wilma $_GET['var'] will be an array inside mypage.php, You should probably check to see if it's an array then, if it is, loop through each element of the var array Chris weetat w

[PHP] Array to String

2006-06-25 Thread weetat
Hi all, I have the error below in my PHP version 4.3.2: PHP Notice: Array to string conversion in /data/html/library/config.php on line 45 If i have turned "on" the magic_quotes in php.ini, it is ok . Any ideas? It cause by the code below: if (!get_magic_quotes_gpc()) { if (isset($_P

Re: [PHP] Array

2006-06-19 Thread John Nichel
Rob W. wrote: $query="SELECT switchport FROM network"; $result=mysql_query($query); $sql_range=array($result['switchport']); Anybody tell me what i'm doing wrong and why this isnt going in to an array? Because you're not understanding what the function mysql_query() is doing. Look at

Re: [PHP] Array

2006-06-19 Thread Brad Bonkoski
Your result variable is a result identifier, not the actual data... check out: http://www.php.net/manual/en/function.mysql-fetch-row.php or something similar... -Brad Rob W. wrote: $query="SELECT switchport FROM network"; $result=mysql_query($query); $sql_range=array($result['switchport'])

RE: [PHP] Array

2006-06-19 Thread Jay Blanchard
[snip] $query="SELECT switchport FROM network"; $result=mysql_query($query); $sql_range=array($result['switchport']); Anybody tell me what i'm doing wrong and why this isnt going in to an array? [/snip] Use mysql_fetch_array() $sql_range = mysql_fetch_array($result); -- PHP General Maili

[PHP] Array

2006-06-19 Thread Rob W.
$query="SELECT switchport FROM network"; $result=mysql_query($query); $sql_range=array($result['switchport']); Anybody tell me what i'm doing wrong and why this isnt going in to an array?

SV: [PHP] Array name out of field value with data

2006-05-22 Thread Jonas Rosling
-Ursprungligt meddelande- Från: nicolas figaro [mailto:[EMAIL PROTECTED] Skickat: den 22 maj 2006 11:50 Till: PHP List Ämne: Re: [PHP] Array name out of field value with data Jonas Rosling a écrit : > Not so sure if I've tried to work this out before in this list. > I'm t

Re: [PHP] Array name out of field value with data

2006-05-22 Thread nicolas figaro
Jonas Rosling a écrit : Not so sure if I've tried to work this out before in this list. I'm trying to make an array name by a field/row value and assigning values to it. But I'm having some problems getting it to work. Is it possible to do this? And if, what am I doing wrong? Or is there any othe

[PHP] Array name out of field value with data

2006-05-22 Thread Jonas Rosling
Not so sure if I've tried to work this out before in this list. I'm trying to make an array name by a field/row value and assigning values to it. But I'm having some problems getting it to work. Is it possible to do this? And if, what am I doing wrong? Or is there any other way to do it? while($ro

<    1   2   3   4   5   6   7   8   9   10   >