Jump to content

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);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.