2016-07-04 6 views
0

항목 :배열에 항목을 추가하는 방법은 무엇입니까?

$image = wp_get_attachment_image_src(get_post_thumbnail_id($loop->post->ID), 'single-post-thumbnail'); 

배열 :

$attachment_ids = $product->get_gallery_attachment_ids(); 

foreach($attachment_ids as $attachment_id) 
{ 
    echo '<img src="'.$image_link = wp_get_attachment_url($attachment_id).'">'; 
} 

내가 배열의 시작 부분에있는 항목 $의 img_url를 추가해야합니다.

+0

여기서 id $ img_url은 무엇입니까? 어떤 배열에 추가할까요? –

+0

무엇이'$ img_url'인지 나는 그것을 보지 못한다. – ArtisticPhoenix

답변

0

배열의 시작 부분에 항목을 추가하려면 array_unshift()을 사용할 수 있습니다.

<?php 
array_unshift($attachment_ids, $img_url); 
관련 문제