How to save each array values in next line?

by Suraj   Last Updated December 14, 2017 14:07 PM

I am having a requirement that, automating the contributed module configurations via hook_update. I have a text area, where i need to mention different URLs with one URL/line. For reference look into the image:

enter image description here

To achieve this I have to use variable_set(); function. I tried something like below but not able to get all the values displayed.

$test = array('abc/*','xyz/*','ijk/*');
variable_set('boost_testing', $test);

This code is setting only first row, it will not come to next row.

So please suggest something I can do by using <br> or \n so that i can display each values next row. Any help will be appreciated.



Answers 1


You should pass paths as a string instead of array:

$test = "abc/*\nxyz/*\nijk/*\n";
variable_set('boost_testing', $test);

Remember to use double quotes for the $test string.

Vishal Patil
Vishal Patil
December 14, 2017 13:36 PM

Related Questions


How to set value for select list in hook_update?

Updated December 14, 2017 07:07 AM

How do I update the configuration of a theme?

Updated June 08, 2016 08:03 AM

Theme doesn't appear to be enabled, but still in use

Updated January 22, 2018 16:07 PM

Boost, not caching - Drupal 7

Updated June 06, 2015 22:03 PM