PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Get array as string --
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Get array as string --

Réponse
 
LinkBack Outils de la discussion
Vieux 09/05/2008, 11h40   #1
Shelley
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Get array as string --

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

  Réponse avec citation
Vieux 09/05/2008, 11h42   #2
James Dempster
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Get array as string --

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
>


  Réponse avec citation
Vieux 09/05/2008, 13h15   #3
Chetan Rane
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Get array as string --

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 --

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

  Réponse avec citation
Vieux 09/05/2008, 13h17   #4
Chetan Rane
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Get array as string --

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 --

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

  Réponse avec citation
Vieux 09/05/2008, 13h36   #5
Zoltán Németh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Get array as string --

> 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 --
>
> 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
>
>



  Réponse avec citation
Vieux 09/05/2008, 13h57   #6
Chetan Rane
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] Get array as string --

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 --

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 --

> 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 --
>
> 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




  Réponse avec citation
Vieux 09/05/2008, 13h59   #7
Thiago Pojda
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RES: [PHP] Get array as string --

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 --

> 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 --
>
> 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




  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h05.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13264 seconds with 15 queries