|
@@ 73-84 (lines=12) @@
|
| 70 |
|
* |
| 71 |
|
* @return array The converted array. |
| 72 |
|
*/ |
| 73 |
|
public static function str_to_arr( &$input ) { |
| 74 |
|
if ( ! is_array( $input ) ) { |
| 75 |
|
// Explode string > Trim each entry > Remove blanks > Re-index array. |
| 76 |
|
$input = array_values( array_filter( array_map( 'trim', explode( ',', $input ) ) ) ); |
| 77 |
|
} else { |
| 78 |
|
// If we're already an array, make sure we return it clean. |
| 79 |
|
self::arr_to_str( $input ); |
| 80 |
|
self::str_to_arr( $input ); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
return $input; |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
/** |
| 87 |
|
* Convert an array to a string with comma seperated values. |
|
@@ 95-106 (lines=12) @@
|
| 92 |
|
* |
| 93 |
|
* @return string The converted string. |
| 94 |
|
*/ |
| 95 |
|
public static function arr_to_str( &$input ) { |
| 96 |
|
if ( is_array( $input ) ) { |
| 97 |
|
// Trim each entry > Remove blanks > Implode them together. |
| 98 |
|
$input = implode( ',', array_filter( array_map( 'trim', $input ) ) ); |
| 99 |
|
} else { |
| 100 |
|
// If we're already a string, make sure we return it clean. |
| 101 |
|
self::str_to_arr( $input ); |
| 102 |
|
self::arr_to_str( $input ); |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
return $input; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* Encrypt the passed string with the passed key. |