PHP - Need help with Array and Explode

by 2 replies
3
With a string $string1 = "One Two Three",

I need to create an array like this $desiredarray = ("One Two Three", "One", "Two", "Three")

I can create an array ("One", "Two", "Three"), by $words = explode($string1).

How do I combine $string1 and $words to get $desiredarray?

Thanks.
#programming #array #explode #php
  • Example #1 array_push() example


    The above example will output:

    Array
    (
    [0] => orange
    [1] => banana
    [2] => apple
    [3] => raspberry
    )
    • [1] reply
    • Thank you very much Arine. Much appreciated. Merry Christmas!

Next Topics on Trending Feed