I have this code which gives me post_permalink
in a while loop.
<?php
$value[] = array();
while ($the_query->have_posts()) : $the_query->the_post()
$value[] =array(
'post_permalink' => get_permalink()
);
endwhile; ?>
Now the thing is that I'm getting the links
as
Array ( [0] => Array ( [post_permalink] => link )
[1] => Array ( [post_permalink] => link )
[2] => Array ( [post_permalink] => link )
[3] => Array ( [post_permalink] => link ) )
The way I want it to be:
Array ( [post_permalink] => link
[post_permalink] => link
[post_permalink] => link
[post_permalink] => link )
i.e: All of the links in one array instead of four subarrays. Please help!
foreach($value[0] as $k=>$v)
$result[$k]=$v
The example of what you want is not possible as array keys are unique.
You probably want something like:
$value['post_permalink'][] = get_permalink();
You can't have an array the way you want it because each array key must be unique. This will work:
$values = array();
while($the_query->have_posts()) : $the_query->the_post();
$values[] = get_permalink();
endwhile;