Search code examples
phparrayslaravelstring-conversion

Building a string from an array in laravel


This is the array i've received in my controller from doing a POST which is built dynamically based on the number of inputs given by the user. sample_array

I would like to convert it into a string in my controller which would produce something like "test3 or test2 or test" to use in a PHP exec.


Solution

  • You can use implode():

    implode(' or ', $array['emailVal'])