Get array as string --Help

This is a discussion on Get array as string --Help within the PHP General forums, part of the PHP Programming Forums category; Hi all, If I have an array like this: $arr = array ( 'c' => 'd', 'e' => 'f'); How can I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 4 Days Ago
Shelley
 
Posts: n/a
Default Get array as string --Help

Hi all,

If I have an array like this:
$arr = array (
'c' => 'd',
'e' => 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

--
Regards,
Shelley

Reply With Quote
  #2 (permalink)  
Old 4 Days Ago
James Dempster
 
Posts: n/a
Default Re: [PHP] Get array as string --Help

serialize

--
/James

On Fri, May 9, 2008 at 10:40 AM, Shelley <myphplist@gmail.com> wrote:

> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>


Reply With Quote
  #3 (permalink)  
Old 3 Days Ago
Chetan Rane
 
Posts: n/a
Default RE: [PHP] Get array as string --Help

What is the format you want it to be

You can use JSON_encode(array());

To get into a text like representation

Chetan Dattaram Rane
Software Engineer



-----Original Message-----
From: Shelley [mailto:myphplist@gmail.com]
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [php] Get array as string --Help

Hi all,

If I have an array like this:
$arr = array (
'c' => 'd',
'e' => 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

--
Regards,
Shelley

Reply With Quote
  #4 (permalink)  
Old 3 Days Ago
Chetan Rane
 
Posts: n/a
Default RE: [PHP] Get array as string --Help

Yet another option is use serialize(array())

Chetan Dattaram Rane
Software Engineer



-----Original Message-----
From: Shelley [mailto:myphplist@gmail.com]
Sent: Friday, May 09, 2008 3:11 PM
To: PHP General list
Subject: [php] Get array as string --Help

Hi all,

If I have an array like this:
$arr = array (
'c' => 'd',
'e' => 'f');

How can I convert this array into a string? I want to write an array into a
file.

Thanks in advance.

--
Regards,
Shelley

Reply With Quote
  #5 (permalink)  
Old 3 Days Ago
Zoltán Németh
 
Posts: n/a
Default RE: [PHP] Get array as string --Help

> Yet another option is use serialize(array())

or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh

>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist@gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [php] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



Reply With Quote
  #6 (permalink)  
Old 3 Days Ago
Chetan Rane
 
Posts: n/a
Default RE: [PHP] Get array as string --Help

Yea but implde will loose the "Keys"

Chetan Dattaram Rane
Software Engineer


-----Original Message-----
From: Thiago Pojda [mailto:thiago.pojda@softpartech.com.br]
Sent: Friday, May 09, 2008 5:30 PM
To: 'Zoltán Németh'; 'Chetan Rane'
Cc: 'Shelley'; 'PHP General list'
Subject: RES: [php] Get array as string --Help

Depending on your needs you could also use implode() and then save it to a
file.


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda@softpartech.com.br
Excelęncia em Softwares Financeiros


-----Mensagem original-----
De: Zoltán Németh [mailto:znemeth@alterationx.hu]
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [php] Get array as string --Help

> Yet another option is use serialize(array())


or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh

>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist@gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [php] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> 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




Reply With Quote
  #7 (permalink)  
Old 3 Days Ago
Thiago Pojda
 
Posts: n/a
Default RES: [PHP] Get array as string --Help

Depending on your needs you could also use implode() and then save it to a
file.


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
thiago.pojda@softpartech.com.br
Excelęncia em Softwares Financeiros


-----Mensagem original-----
De: Zoltán Németh [mailto:znemeth@alterationx.hu]
Enviada em: sexta-feira, 9 de maio de 2008 08:37
Para: Chetan Rane
Cc: 'Shelley'; 'PHP General list'
Assunto: RE: [php] Get array as string --Help

> Yet another option is use serialize(array())


or you could use var_export if you need php code
http://php.net/var_export

greets,
Zoltán Németh

>
> Chetan Dattaram Rane
> Software Engineer
>
>
>
> -----Original Message-----
> From: Shelley [mailto:myphplist@gmail.com]
> Sent: Friday, May 09, 2008 3:11 PM
> To: PHP General list
> Subject: [php] Get array as string --Help
>
> Hi all,
>
> If I have an array like this:
> $arr = array (
> 'c' => 'd',
> 'e' => 'f');
>
> How can I convert this array into a string? I want to write an array into
> a
> file.
>
> Thanks in advance.
>
> --
> Regards,
> Shelley
>
>
> --
> 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




Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0