PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Re: How to display Array
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: How to display Array

Réponse
 
LinkBack Outils de la discussion
Vieux 28/03/2008, 05h34   #1
adwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to display Array

use echo '<pre>'; print_r($array) ; echo '</pre>';

or use
foreach($array as $key => $subarray)
{
echo $subarray['HOTEL_ROOMS'];
forach($subarray['ROOM'] as $key => $anotherarray)
{
write here what you need !
}
}
  Réponse avec citation
Vieux 30/03/2008, 20h42   #2
SOLVER
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to display Array

On 28 Mar, 05:34, adwin <adwin.wij...@gmail.com> wrote:
> use echo '<pre>'; print_r($array) ; echo '</pre>';
>
> or use
> foreach($array as $key => $subarray)
> {
> echo $subarray['HOTEL_ROOMS'];
> forach($subarray['ROOM'] as $key => $anotherarray)
> {
> write here what you need !
> }
>
> }


This will not work...
There is array like that:
[ROOM][0][...]
[ROOM][1][...]
[ROOM][2][...]
[ROOM][3][...]

How to dispaly something like that if I dont know how many rooms will
be?
At the moment I using function 'for' inside the function 'foreach'.
But this will not work when is only one room:
[ROOM][...]


Mariusz
  Réponse avec citation
Vieux 30/03/2008, 21h20   #3
Alexey Kulentsov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to display Array

SOLVER wrote:
> How to dispaly something like that if I dont know how many rooms will
> be?
> At the moment I using function 'for' inside the function 'foreach'.
> But this will not work when is only one room:
> [ROOM][...]

'variable must be array' error?

You can check if(is_array(...)) for this case but I recommend you
rewrite data creating subroutine to have array with one element in the
case of one room and empty array in here are no rooms.
  Réponse avec citation
Vieux 30/03/2008, 22h42   #4
George Maicovschi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to display Array

On Mar 30, 11:20 pm, Alexey Kulentsov <a...@inbox.ru> wrote:
> SOLVER wrote:
> > How to dispaly something like that if I dont know how many rooms will
> > be?
> > At the moment I using function 'for' inside the function 'foreach'.
> > But this will not work when is only one room:
> > [ROOM][...]

>
> 'variable must be array' error?
>
> You can check if(is_array(...)) for this case but I recommend you
> rewrite data creating subroutine to have array with one element in the
> case of one room and empty array in here are no rooms.


You'll have to write your own function to do that thing.
  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 19h23.


É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,08060 seconds with 12 queries