Skip to content
Advertisement

add array value in php

Hello Iam new in Php I have Some Dout in Array this is my array

Array
(
    [files] => Array
        (
            [2] => abc.zip
            [3] => xyz.rar
       )
)

I need to add String in Array Values.. Like this

Array
(
    [files] => Array
        (
            [2] => domain.com/abc.zip
            [3] => domain.com/xyz.rar
       )
)

I want Add Every Values domain.com/ How his Possible(sorry for bad English)

Advertisement

Answer

Just a simple loop and concat…

foreach($array['files'] as $key=>$value){
  $array['files'][$key] = "domain.com/".$value;
}
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement