Hi! I have a relatively

Loading

Hi! I have a relatively simple question, or so i think! I have two arrays of strings, and i want to be able to concatenate each element of the first array with each element of the second. I have tried a couple of things and they did not work out. Can i get some help?

Here's an example of what i'm trying to do.
$firstarray[] = array("hello", "world");
$secondarray[] = array("good", "day");
I want to be able to produce a third array which contains:
$thirdarray[] = array ("hello good", "world day");

Is that possible? I have tried looping and a couple of other things to concatenate each element of the first string with each element but with no success. I don't get the required output. Please help.


You can sure do that with

You can sure do that with couple of foreach loops.

But can you explain what exactly you're trying to do? Perhaps, you could avoid concatenating each array element like this.

Hi Sudheer! This is about as

Hi Sudheer! This is about as precise as i can be.

$firstarray[] = array("good", "morning");
$second[] = array("good", "day");
I wish get $result = array("good good", "morning day");

I have tried foreach loops i think, with little success. Maybe i was missing something. Thank you for replying.

I got it. :)

I got it. :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>. The supported tag styles are: <foo>, [foo].

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.