$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?
- 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
- Display all meta for a post?
- Need to get specific data from array
- Create an array from an array
- how to increase custom post value by one most efficiently?
- Must Use Plugin Causing Query Error
- How to Display Image Meta underneath EVERY image in EVERY post
- How to convert objects into arrays
- Parsing php string in jquery [closed]
- Admin Options page. Save as Array
- PHP get the first post separately from array returned by wpdb->get_results()
- how can i show only the parents in owl-carousel?
- 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
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Call global variable array() in woocommerce child/template
- Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)
- Populate dropdown with Child Pages based on Parent Page chosen
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- foreach loop still echoes array
- WordPress update_post_meta updating with empty meta_value field [closed]
- meaning of (array)function()
- Non-Closing PHP Query in WordPress Loop
- 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 to use if statement in an array? [closed]
- 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]
- update_post_meta only updating on last loop of foreach
- How to use array in function to get only value I want
- Get categories names as an array to use it in theme settings
- how to get serialized post meta
- How to get the last category name of a child category?
- Warning: in_array() null given in PHP function
- Foreach loop inside an array_merge
- How to access or parse key/values that have “string”
- Getting posts to exclude from array
- How to add post meta in while loop?
- Add category to post meta
- Comapare get_user_meta value
- How can get all users by current user meta?
- how to make an array of post id’s in is_single
- How can I split my query result in 2 arrays?
- array_rand not working correctly?
- Get css class of menu item in custom menu structure
- Dynamically adding filters
- Add a custom class to the body tag using custom fields
- Unable to Call More than One Meta Box Output
- Hide a div when a custom field is empty
- Post meta select input, if statement
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- Using multiple variables to assign categories to an array
- WordPress stripping out custom field tags
- Repeat a function with 24hrs gap for n number of days
- Sending simple variable on single page to WP JSON
- Order users by random not working?
- How to update custom fields when post is published?
- Update Images after edit via php
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- No more get_option(‘date_time’) in WordPress 5.5?
- Delete post meta by serialized meta value
- Show a text if the post has written by author user role in WordPress
- How to filter specific element of an array in wordpress/php?
- Reverse Cross-Sells (WooCommerce)
- Store custom field’s multiple values in one user meta key
- Make sticky post with FacetWP
- Post Meta statement?
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Trouble with checked() for array of multiple checkboxes
- WordPress AJAX load post metadata in modal
- How to use foreach and if statement within array of arrays?
- get_post_meta with variable
- WP_Post is not from correct array
- How to find the function which is outputting Array
- Exclude Post ID from Array Specified in Custom Field
- Postmeta not saving
- Adapting a php array to WordPress
- How to add together (get the sum) a field from all author’s posts
- What is this mark for “? function()” [closed]
- How to combine array info [closed]
- PHP Use Declared array Variable inside already Declared Array
- Force array to be a string [closed]
- Why is my array_diff usage breaking things?
- get_body_params() is always empty in POST request
- Grabbing value of input field inside of array
- How to group by column a and sum column b and c in a php array
- PHP how to submit array elements to database