Jump to content

insert array vales into sting of another array


denoteone

Recommended Posts

I have an array $array_1

ARRAY(
[0] => info 1
[1] => info 2
[2] => info 3
)

 

and I have another array $array_2

ARRAY(
[0] =>thank you and welcome to what ever
[1] =>the info you added * thanks for entering your info
)

I want to loop though the first array and place the values into the [1] of the second array. But the tricky thing is I want it to insert were the * is.

 

 

foreach ($array_1  as $key =>  $val) {
    //not sure about this 
    insert into ($array_2[1],after *, $val);
} 

 

any help would be awesome.

try

<?php
$array1 = array('info 1', 'info 2', 'info 3'); 
$array2 = array('thank you and welcome to what ever', 'the info you added * thanks for entering your info');
foreach ($array1 as $val) $array2[1] = str_replace('*', "* ".$val, $array2[1]);
print_r($array2);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.