wc_string_to_array

Explode a string into an array by $delimiter and remove empty values.

Description

(array) wc_string_to_array( (string) $string, (string) $delimiter = ',' ); 

Returns (array)

Parameters (2)

0. $string (string)
The string.
1. $delimiter — Optional. (string) => ','
The delimiter.

Usage

  1. if ( !function_exists( 'wc_string_to_array' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The string. 
  5. $string = ''; 
  6.  
  7. // The delimiter. 
  8. $delimiter = ','; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_string_to_array($string, $delimiter); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_string_to_array( $string, $delimiter = ', ' ) { 
  2. return is_array( $string ) ? $string : array_filter( explode( $delimiter, $string ) );