$boat_safety_terms_cleaned_sorted = sort( $boat_safety_terms_cleaned );
error_log( print_r( $boat_safety_terms_cleaned_sorted, TRUE ) );
PHP’s sort accepts an array reference and sorts in-place, and returns success or failure – hence the 1 you’re getting. You want:
sort( $boat_safety_terms_cleaned );
error_log( print_r( $boat_safety_terms_cleaned, TRUE ) );
Also, I’m assuming I’ll want to use update_post_meta to save the array back to the field?
Yes, that would work fine. I assume this is utility method that you’ll manually trigger once per post though, and not something that gets run as a matter of course? If it’s on save of a boat then there are probably better ways to filter the value as you save it, depending on how you’re doing that.
Related Posts:
- How can merge two arrays values in one array and save in database
- How to update single value in multi dimensional Post Meta?
- Compare two meta key values against each other inside the get_posts array?
- How to use two meta_compare in an array?
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Order a WP_Query by meta value where the value is an array
- Update value of a associative array with update_post_meta
- WP post meta – for loop inside for loop
- Remove item from post_meta array via AJAX
- How to update custom fields using the wp_insert_post() function?
- Get meta_id along with meta_key and meta_value
- Sorting list of sites from multisite network using wp_get_sites
- How to store the_title() into a variable to reutrn the value, not just echo it
- Metabox repeating fields – radio buttons not saving correctly
- Check if user already visited this post today
- Display all meta for a post?
- How to display multiple Post meta_key/meta_values by SQL query
- the_post_thumbnail() based on the Post ID
- How to use multiple query with same meta key
- Error in WP_update_post
- Why is my get_post_meta always empty
- How can update custom meta for all posts
- Looping through WP_Post Object
- Need to get specific data from array
- Using a javascript file to access a get posts array
- Create an array from an array
- WP_User_Query order by meta_key that is an array
- Use ajax to update_post_meta
- Generate an array of parent/child page IDs, based on parent page name
- How do I output a database option that is an array into a get_posts array?
- Can an array be used as a meta_query value?
- Listing and displaying WooCommerce Shipping Zones in the frontend? [closed]
- How do I dynamically generate args for wp_query?
- List of posts by day of the week
- Check if term object is in array
- how to increase custom post value by one most efficiently?
- Batch update a post meta field value of each post in Post Type
- Must Use Plugin Causing Query Error
- How to Display Image Meta underneath EVERY image in EVERY post
- ‘orderby’ => ‘rand’ alternative for better performance?
- How to convert objects into arrays
- Change description on specific WooCommerce product status change
- Parsing php string in jquery [closed]
- Admin Options page. Save as Array
- Use WP_Query in shortcode
- PHP get the first post separately from array returned by wpdb->get_results()
- Working with query_posts ( arrays and query strings)
- how can i show only the parents in owl-carousel?
- Create shortcodes within foreach loop (using array)
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Using a variable in is_page(array())
- Random order of WP_Query results with highest meta value
- Remove duplicates – array_unique()
- How can I add multiple ‘tax_query’ arrays via a loop?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- The text box have space character
- how to remove metadata from the posts of my blog?
- How can I create a list of page titles from custom meta values?
- Trying to remove post thumbnail with plugin
- Recent posts with featured image or fallback image with permalink
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Call global variable array() in woocommerce child/template
- Storing Array from returned database query and using the array in a new query
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- get_*_meta doesn’t always return an array
- get_the_tags() not iterating through for/while loop, but will with foreach
- get a simple array of all of the term names that exist in all taxonomies
- Populate dropdown with Child Pages based on Parent Page chosen
- How to use $query->set with post__in?
- Sort custom meta column by other meta value
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- Reprinting tags with all attributes
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Creating user status mode in WordPress
- Need help with Google drive API [closed]
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- foreach loop still echoes array
- Exclude posts based on meta value
- Archive post by meta value + 24hours
- Checking array against author id in loop
- WordPress update_post_meta updating with empty meta_value field [closed]
- Alter required message using comment form api
- Advanced Custom Fields – display label and value only if value entered
- Is it possible to retrieve all posts with a certain value for metadata?
- Get post id within comments loop
- meaning of (array)function()
- Grouping posts by a custom meta value
- Non-Closing PHP Query in WordPress Loop
- wp_force_remove_style’ not found
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- Output meta into arrays
- Querying Database with wpdb
- Get html data with javascript to php array and store to wordpress database
- How do I create a numbered list with PHP? [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- update_post_meta only updating on last loop of foreach