How to merge strings


#1

Hi all,

since some weeks I learn php combined with HTML and Java Script.
I would like to bring 8 strings together in pairs. I have now searched the manual for hours and unfortunately found nothing.

That is what it looks like (via “view-source”):

Array
(
    [0] => AB
    [1] => CD,
    [2] => EF
    [3] => GH,
    [4] => IJ
    [5] => KL,
    [6] => MN
    [7] => OP,
)

and I want it to look like this:

Array
(
    [0] => AB CD
    [1] => EF GH
    [2] => IJ KL
    [3] => MN OP
)

Is there a simple way to merge the strings?

Thanks,
DrK


#2

How do you end up with the array in the first place?


#3

Hi JimL,

that was my last try to get this done:

image

I was searching for the most simple way to do this by implode and explode…

Thanks


#4

Tell us what the real problem is instead of asking how to solve your attempted solution to the problem.


#5

I splitted the strings with my last try:

image

but I have no idea, how to merge them again in the right way…that’s my problem.

Thanks


#6

No, this is your attempt at solving the real problem. What is this array all about? What is the overall problem this attempt is supposed to solve?