2013-08-21 2 views
1
include 'core/init.php'; 
include 'includes/overall/header.php'; 

$post_id = $_GET['post_id']; 

$check_like = mysql_query("SELECT liker, liker_username FROM `likes` WHERE `post_id`='$post_id' "); 
       while($run_check_like = mysql_fetch_assoc($check_like)) { 

       $post_liker[] = $run_check_like['liker']; 

       $post_liker_profile[] = $run_check_like['liker_username'];   
     } 

include 'includes/overall/footer.php'; 

배열 하나에 $ post_liker이고; 배열 2는 $ post_liker_profile입니다.이차원 배열로 동일한 길이를 갖는 두 개의 배열을 결합하는 방법

나는 sth를 울리고 싶습니다. as $ post [$ post_liker] [$ post_liker_profile];

+0

'post_id' 필드에 SQL injection exploit이 있음에 유의하십시오. 'intval()'또는'addslashes()'와 같은 방식으로 위생 처리하십시오. – Codecat

답변

0

다음과 같은 것을 사용하고 싶습니까? array_combine?

$post = array_combine($post_liker, $post_liker_profile); 
+0

네, 작동하지만 어떻게이 어레이의 개별 값을 출력 할 수 있습니까? exaple post [] []; foreach 루프를 사용하고 있습니까? –

+0

@RexhinHoxha [print_r] (http://us2.php.net/manual/en/function.print-r.php)을 찾고 계십니까? –

+0

아니오, print_r을 사용하지 않으려 고합니다. –

0

$ i = 0;

$ array [$ i] [$ i] = $ array_one [$ i]. "*". $ array_two [$ i];

저장하는 동안 이와 같이 사용하려고하면 다시 값이 필요할 경우 다시 *를 사용하여 분할을 사용할 수 있습니다.

배열 값에 * 존재하지 않는 다른 것을 사용하면 *.

관련 문제