I\'m using this function to get an array of custom meta fields in WordPress
$my_var = get_meta_values( \'keywords\' );
if( !empty( $my_var ) ) {
$meta_counts
Please try code given below
if( !empty( $my_var ) ) {
$meta_counts = array();
$total_count = 0;
foreach( $my_var as $meta_index=>$meta_value ){
if(isset($meta_index) && !empty($meta_index)){
$meta_index_arr = explode(',', $meta_index);
$meta_counts[$meta_index] = count($meta_index_arr);
$total_count += $meta_counts[$meta_index];
}else{
$meta_counts[$meta_index] = 0;
}
}
}
print_r ($meta_counts);
echo $total_count;
thanks
you can get 13 words or phrases by this
$words = array_map('trim', explode(',', implode(',', array_keys($meta_counts))));
There is a function called explode that lets you split the array.
Here is the link for it.
This should probably do some need.
http://php.net/manual/en/function.explode.php