问题是这样的...
现有数组:
Array(
[0] => array('sample 1', 'sample 2')
[1] => array('cat', 'dog')
)
另一个数组:
Array(
[0] => array('sample 3', 'sample 4')
)
我想要将它添加到 0 键旁边,所以它变成了:
Array(
[0] => array('sample 1', 'sample 2')
[1] => array('sample 3', 'sample 4')
[2] => array('cat', 'dog')
)
你怎么做到这一点?
@maxhud 我试过了,结果是这样的:
Array(
[0] => sample 1
[1] => sample 2
[2] => sample 3
[3] => sample 4
[4] => cat
[6] => dog
)
这是我当前的代码片段
$new_post_order = array();
foreach($the_query['posts'] as $the_post) {
$portfolio_reorder = '';
$portfolio_reorder = get_post_meta($the_post['ID'], 'portfolio_reorder', true); // Get the order on the db
if(empty($portfolio_reorder)) { // If its empty...
$portfolio_reorder = 0; // Add default order
}
array_splice($new_post_order, $portfolio_reorder, 0, $the_post);
}
echo '<pre>';
print_r( $new_post_order );
echo '</pre>';