I am trying to add some additional things to an array but am getting lost somewhere along the line, I have the following code…..
<?php
foreach ($search_values as $key => $value)
{
echo "'";
echo $key;
echo "'";
echo " => ";
echo "'";
echo $value;
echo "'";
echo " , ";
}
?>
Which produces the following….
'beds' => '2' ,
'property_type' => 'for-rent' ,
'zipcode' => 'se19' ,
I then have the following code that generates a map….
<?php
if ( function_exists( 'pronamic_google_maps_mashup' ) ) {
pronamic_google_maps_mashup(
array(
'post_type' => 'listings' ,
'posts_per_page' => -1
)
);
}
?>
I need to somehow add the results of echoing the first array into this array, can anyone point me in the right direction?
No, you don’t need to add the echoed results into the array — you just need to add the array values onto the other array. This can be done with
array_merge();Don’t think of array contents in terms of how they print on the screen, as that will lead you down the wrong path. PHP has many array functions to accomplish all sorts of tasks.
To get a sense of what your final array will look like, debug it with
var_dump():