foreach loop returns only one item from the array

前端 未结 2 975
轻奢々
轻奢々 2021-01-29 06:54

I have an array that I loop through with for each loop it returns only the first iteration but if I change it to echo it prints all of them to the screen, new to PHP not sure wh

2条回答
  •  执念已碎
    2021-01-29 07:10

    return after loop iterates.

    function getData($values){
            $tags = [];
            foreach ($values as $key => $value){
                $tags[] =  "

    ". $key . " " . $value ."


    "; } return $tags; } $SubmitedResult->SerialisedForm = getData($data);

提交回复
热议问题