웹모아
웹모아[가입] 로그인 / 회원가입   검색     


  
일반팁
 

2차원 배열 - 출력하기
2007-01-14 00:23:30 댓글:(0)   조회:4584
 


<?php
    $ResultText[1][0] = '10';
    $ResultText[1][1] = '11';
    $ResultText[1][2] = '12';
    $ResultText[1][3] = '13';
    $ResultText[1][4] = '14';
    $ResultText[1][5] = '15';

    $ResultText[2][0] = '20';
    $ResultText[2][1] = '21';
    $ResultText[2][2] = '22';
    $ResultText[2][3] = '23';
    $ResultText[2][4] = '24';
    $ResultText[2][5] = '25';

    $ResultText[3][0] = '30';
    $ResultText[3][1] = '31';
    $ResultText[3][2] = '32';
    $ResultText[3][3] = '33';
    $ResultText[3][4] = '34';
    $ResultText[3][5] = '35';

    reset ( $ResultText );
    while (list($Type, $Value) = each ($ResultText))
    {
         reset( $Value );
        for ( $i = 0; $i < count( $Value ); $i++ )
        {
            echo count($Value).'     ';
            echo "Type : $Type; Value: $Value[$i] <br>";
        }
    }
   echo "34 : ".$ResultText[3][4]."<br>";

   $tmp_count = count($ResultText[1]);
   echo "배열갯수 tmp_count : $tmp_count <br>";

   $tmp_count2 = count($ResultText);
   echo "배열갯수 tmp_count2 : $tmp_count2 <br>";

?>
========================================== 결과 ==========================================
6 Type : 1; Value: 10 
6 Type : 1; Value: 11 
6 Type : 1; Value: 12 
6 Type : 1; Value: 13 
6 Type : 1; Value: 14 
6 Type : 1; Value: 15 
6 Type : 2; Value: 20 
6 Type : 2; Value: 21 
6 Type : 2; Value: 22 
6 Type : 2; Value: 23 
6 Type : 2; Value: 24 
6 Type : 2; Value: 25 
6 Type : 3; Value: 30 
6 Type : 3; Value: 31 
6 Type : 3; Value: 32 
6 Type : 3; Value: 33 
6 Type : 3; Value: 34 
6 Type : 3; Value: 35 
34 : 34

배열갯수 tmp_count : 6 
배열갯수 tmp_count2 : 3

. 


[이전글]  [RE] 쿼리결과 2차원 배열로 저장하기
[다음글]  EchoError (MySQL)


 
댓글쓰기는 회원(로그인 하신분) 이상 가능합니다.


 댓글 (0)

  
일반팁
페이지: 1 / 10   

 php 한글 영어 일어 한자 구분 방법
열람:2107   2021.04.12


 중복 글등록을 방지하는 간단한 팁
열람:14463   2017.05.21


 이전 페이지 돌아가기 예제소스 코드보기
열람:3260   2017.03.14


 현재페이지 파일명 구하기
열람:6129   2016.12.25


 반응형 웹에서 발생할 수 있는 시각적 요소의 크기 조절 문제
열람:8283   2016.07.12


 php 한글(UTF-8) 자르기
열람:4585   2015.07.09


 php header를 utf-8 로 바꾸기
열람:4294   2015.05.25


 게시판에 파일 첨부 갯수가 20개로 제한되는 경우 - php
열람:4145   2013.10.07


 영문 대소문자 변환
열람:4325   2013.09.17


 mime_type 알기
열람:4330   2010.10.26



[1]  [2]  [3]  [4]  [5]  

복수단어 검색은 공백(space)로 구분해 주세요.




 
최근 글 [손님]
 
인기 글 [손님]
[홈마스타] 속도감