How to create a string from an array? All values ​​are initially stored separately in an array. For example, I have an array of names, and I need to get all the values ​​in one line.

  • one
    normally formulate the question because one gets the impression that you yourself do not know what exactly you need, extrasenses are not here ... - Zowie
  • what if I have an array of names, I only need to get all the values ​​in the video line - trane294

1 answer 1

In general, it is not clear what exactly you have entered, as I understand it xD

<? $names = array('Вася','Гриша','Маша','Жора'); for($i=0; $i<count($names); $i++) { echo $names[$i]; //выведет имя... } ?> 

Also, if you have entered an array into a string, then:

 <? $names = array('Вася','Гриша','Маша','Жора'); $namesString = implode(' ', $names); //вместо пробела можно подствалять любую строку... echo $namesString; //Выведет: Вася Гриша Маша Жора ?> 
  • I told you there are psychics here) - trane294