Created
December 5, 2010 22:46
-
-
Save dustincurrie/729560 to your computer and use it in GitHub Desktop.
Safely turn string variable in Drupal (i.e. listing of paths in textfield) into an array and back to a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = preg_split('/\n/', trim(variable_get('string_variable', ''))); | |
//add remove entries in the array | |
variable_set('string_variable', implode("\n", $array)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment