I have an array like this (one dimension only):
$arr = array('one', 'two', 'three', 'foo', 'bar', 'etc');
Now I need a for() loop that creates a new 开发者_开发知识库array from $arr, like that:
$newArr = array('one', 'onetwo', 'onetwothree', 'onetwothreefoo', 'onetwothreefoobar', 'onetwothreefoobaretc');
Seems to be simple but I can't figure it out.
Thanks in advance!
$mash = "";
$res = array();
foreach ($arr as $el) {
    $mash .= $el;
    array_push($res, $mash);
}
$newArr = array();
$finish = count($arr);
$start = 0;
foreach($arr as $key => $value) {
   for ($i = $start; $i < $finish; $i++) {
      if (isset($newArray[$i])) {
         $newArray[$i] .= $value;
      } else {
         $newArray[$i] = $value;
      }
   }
   $start++;
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论