[PHP] Storing Arrays in a database

2005-03-24 Thread Joe Harman
k.. in the past i have been using implode and explode... i have yet to
try serialize yet... but i will be giving it a whirled in about 5
minutes...

Thanks... just looking for a better way to do things
Cheers & thanks for the help!
Joe


On Thu, 24 Mar 2005 14:23:05 -0600, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> check serialize() and unserialize() in manual.
> implode() and explode() functions too.
>
> -afan
>
> Joe Harman wrote:
>
> >Hey,
> >
> >I was curious if anyone here stores arrays in MySQL... and how r u
> >doing this... are you converting the values to a delimited string
> >or is there another way?
> >
> >Thanks
> >Joe
> >
> >
> >
>

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



Re: [PHP] Storing Arrays in a database

2005-03-24 Thread John Nichel
Joe Harman wrote:
Hey,
I was curious if anyone here stores arrays in MySQL... and how r u
doing this... are you converting the values to a delimited string
or is there another way?
Thanks
Joe
http://us4.php.net/serialize
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Storing Arrays in a database

2005-03-24 Thread [EMAIL PROTECTED]
check serialize() and unserialize() in manual.
implode() and explode() functions too.
-afan
Joe Harman wrote:
Hey,
I was curious if anyone here stores arrays in MySQL... and how r u
doing this... are you converting the values to a delimited string
or is there another way?
Thanks
Joe
 

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


RE: [PHP] Storing Arrays in a database

2005-03-24 Thread Chris W. Parker
Joe Harman 
on Thursday, March 24, 2005 12:15 PM said:

> I was curious if anyone here stores arrays in MySQL... and how r u
> doing this... are you converting the values to a delimited string
> or is there another way?

http://php.net/serialize and http://php.net/unserialize are probably
what you want.




Chris.

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



[PHP] Storing Arrays in a database

2005-03-24 Thread Joe Harman
Hey,

I was curious if anyone here stores arrays in MySQL... and how r u
doing this... are you converting the values to a delimited string
or is there another way?

Thanks
Joe

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



Re: [PHP] Storing Arrays?

2004-02-24 Thread Jakes
rather just serialize() it.  didnt read your question properly

"Jakes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> depending  how long you want to keep it, wrap the array in a object and
> then serialize the object in a session variable.
>
> "Nick Wilson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> >
> > * and then Jay Blanchard declared
> > > [snip]
> > > If I wanted to store an array for future use in a MySQL TEXT Column
> > > (dont ask, it's complicated... hehe!) how would I go about it?
> > >
> > > I thought of just putting the results of print_r($myarray); into the
> > > text field and using eval() to get at it later... is that the right
way
> > > to go?
> > > [/snip]
> > >
> > > Yes, that is certainly one right way to go.
> >
> > Actually, serialize() would be better suited I think, but thanks...
> >
> >
> > -- 
> > Nick W

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



Re: [PHP] Storing Arrays?

2004-02-24 Thread Jakes
depending  how long you want to keep it, wrap the array in a object and
then serialize the object in a session variable.

"Nick Wilson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> * and then Jay Blanchard declared
> > [snip]
> > If I wanted to store an array for future use in a MySQL TEXT Column
> > (dont ask, it's complicated... hehe!) how would I go about it?
> >
> > I thought of just putting the results of print_r($myarray); into the
> > text field and using eval() to get at it later... is that the right way
> > to go?
> > [/snip]
> >
> > Yes, that is certainly one right way to go.
>
> Actually, serialize() would be better suited I think, but thanks...
>
>
> -- 
> Nick W

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



Re: [PHP] Storing Arrays?

2004-02-24 Thread Chris Hayes
At 11:10 24-2-04, you wrote:
Hi all,

If I wanted to store an array for future use in a MySQL TEXT Column
(dont ask, it's complicated... hehe!) how would I go about it?
you could consider serialize()

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


Re: [PHP] Storing Arrays?

2004-02-24 Thread Nick Wilson

* and then Jay Blanchard declared
> [snip]
> If I wanted to store an array for future use in a MySQL TEXT Column
> (dont ask, it's complicated... hehe!) how would I go about it?
> 
> I thought of just putting the results of print_r($myarray); into the
> text field and using eval() to get at it later... is that the right way
> to go?
> [/snip]
> 
> Yes, that is certainly one right way to go.

Actually, serialize() would be better suited I think, but thanks...


-- 
Nick W

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



RE: [PHP] Storing Arrays?

2004-02-24 Thread Jay Blanchard
[snip]
If I wanted to store an array for future use in a MySQL TEXT Column
(dont ask, it's complicated... hehe!) how would I go about it?

I thought of just putting the results of print_r($myarray); into the
text field and using eval() to get at it later... is that the right way
to go?
[/snip]

Yes, that is certainly one right way to go.

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



[PHP] Storing Arrays?

2004-02-24 Thread Nick Wilson
Hi all, 

If I wanted to store an array for future use in a MySQL TEXT Column
(dont ask, it's complicated... hehe!) how would I go about it?

I thought of just putting the results of print_r($myarray); into the
text field and using eval() to get at it later... is that the right way
to go?

Many thanks

-- 
Nick W

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



RE: [PHP] storing arrays

2002-02-18 Thread Rick Emery



-Original Message-
From: Clark [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 17, 2002 11:15 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] storing arrays


I'm having trouble storing my array to a text file, utilizing serialize()
and unserialize().  Could you please show a very basic layout of the proper
way to serialize and unserialize and store that to a file?  Thanks.

"Matt" <[EMAIL PROTECTED]> wrote in message
001e01c1b7c0$404d5be0$059aa8c0@Pooch">news:001e01c1b7c0$404d5be0$059aa8c0@Pooch...
>
> - Original Message -
> From: "Clark" <[EMAIL PROTECTED]>
> Sent: Saturday, February 16, 2002 9:15 PM
>
>
> > Two questions:
> >
> > 1) Is it possible to write an array to a file?
>
> Yes, serialize it first with http://www.php.net/serialize.  You can also
> place this in a db text field because it will be a character
representation.
>
> > 2) Is it possible to specify the name of the key to each item of an
array
> > when you get the array using file().
>
> When retrieving the saved array, unserialize it, and you'll get the same
> array back.
>



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

2002-02-17 Thread Clark

I'm having trouble storing my array to a text file, utilizing serialize()
and unserialize().  Could you please show a very basic layout of the proper
way to serialize and unserialize and store that to a file?  Thanks.

"Matt" <[EMAIL PROTECTED]> wrote in message
001e01c1b7c0$404d5be0$059aa8c0@Pooch">news:001e01c1b7c0$404d5be0$059aa8c0@Pooch...
>
> - Original Message -
> From: "Clark" <[EMAIL PROTECTED]>
> Sent: Saturday, February 16, 2002 9:15 PM
>
>
> > Two questions:
> >
> > 1) Is it possible to write an array to a file?
>
> Yes, serialize it first with http://www.php.net/serialize.  You can also
> place this in a db text field because it will be a character
representation.
>
> > 2) Is it possible to specify the name of the key to each item of an
array
> > when you get the array using file().
>
> When retrieving the saved array, unserialize it, and you'll get the same
> array back.
>



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




Re: [PHP] storing arrays

2002-02-17 Thread Matt


- Original Message -
From: "Clark" <[EMAIL PROTECTED]>
Sent: Saturday, February 16, 2002 9:15 PM


> Two questions:
>
> 1) Is it possible to write an array to a file?

Yes, serialize it first with http://www.php.net/serialize.  You can also
place this in a db text field because it will be a character representation.

> 2) Is it possible to specify the name of the key to each item of an array
> when you get the array using file().

When retrieving the saved array, unserialize it, and you'll get the same
array back.


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




Re: [PHP] storing arrays

2002-02-17 Thread Joffrey van Wageningen

- Original Message - 
From: "Clark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 17, 2002 3:15 AM
Subject: [PHP] storing arrays


> Two questions:
> 
> 1) Is it possible to write an array to a file?

not direct, use:

$fp = fopen("/my/file", "w");
foreach($filearray as $row)
  fputs($fp, $row."\n");
fclose($fp);

> 2) Is it possible to specify the name of the key to each item of an
> array when you get the array using file().

not direct, use:

$keys = array("first", "second", "third", "fourht");
$filearray = file("/my/file");

for($x = 0; $x < count($filearray); $x++)
  $newfilearray[$keys[$x]] = $filearray[$x];

$filearray = $newfilearray;

i think only a write version of file could be a useful function for php...

mvgr,
Joffrey van Wageningen

--
.-[ Joffrey van Wageningen | WoLFjuh | [EMAIL PROTECTED] ]--
| Networking Event 2000 - www.ne2000.nl - IRCnet:#ne2000, Undernet:#clue
| PGP:1024D/C6BA5863 - 3B93 52D3 CB91 9CB7 C50D FA79 865F 628A C6BA 5863
| * We demand guaranteed rigidly defined areas of doubt and uncertainty.
|   -- Douglas Adams



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




[PHP] storing arrays

2002-02-16 Thread Clark

Two questions:

1) Is it possible to write an array to a file?
2) Is it possible to specify the name of the key to each item of an array
when you get the array using file().

Thanks a lot.



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