|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 ! } } |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|