Title: Another notice, Array to string conversion
Last modified: August 30, 2016

---

# Another notice, Array to string conversion

 *  [klode](https://wordpress.org/support/users/klode/)
 * (@klode)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/another-notice-array-to-string-conversion/)
 * After the last update, I got this notice:
 * `Notice: Array to string conversion in /var/www/vhosts/abruzzotravelling.com/
   httpdocs/resources/plugins/ns-seo-custom-fields/ns-seo-custom-fields.php on line
   250`
 * So, I’ve changed the code around the line 250 as follow:
 *     ```
       $meta = get_post_meta( $post_id, $fieldname, true );
       if(!is_array($meta))
       {
           // autodetect outbound links
           $meta = preg_replace( '/(?<!href=[\'"])((http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}((\/|\?)[\w\/#&?%~]*)?)/', '<a href="$1">$1</a>', (string)$meta );
           // append it to the content
           $content .= " " .(string)$meta;
       }
       ```
   
 * Any other suggestion, maybe from developer, is so appreciate for this great plugin!
 * [https://wordpress.org/plugins/ns-seo-custom-fields/](https://wordpress.org/plugins/ns-seo-custom-fields/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Never Settle](https://wordpress.org/support/users/neversettle/)
 * (@neversettle)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/another-notice-array-to-string-conversion/#post-6740101)
 * $meta = get_post_meta( $post_id, $fieldname, true ); by function definition should
   always be returning a string as it’s the ‘single’ value is set to true. The fact
   that it isn’t is interesting and we’ll look into that.
 * After you added your condition to check to make sure it wasn’t an array – did
   that fix the notice for you entirely? And, are you experiencing proper functionality
   regardless of the notice?
 * There shouldn’t be any problems stemming from your fix, though, given the fact
   that the preg_replace function will do nothing if an array is converted to a 
   string so you’re just saving yourself from the notice there.
 * Would you mind posting a screenshot of your settings / meta / toast information
   so that we can try to recreate the problem and see where it’s coming from?

Viewing 1 replies (of 1 total)

The topic ‘Another notice, Array to string conversion’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/ns-seo-custom-fields_5d4634.svg)
 * [NS Custom Fields for WordPress SEO](https://wordpress.org/plugins/ns-seo-custom-fields/)
 * [Support Threads](https://wordpress.org/support/plugin/ns-seo-custom-fields/)
 * [Active Topics](https://wordpress.org/support/plugin/ns-seo-custom-fields/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ns-seo-custom-fields/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ns-seo-custom-fields/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [cast](https://wordpress.org/support/topic-tag/cast/)
 * [string](https://wordpress.org/support/topic-tag/string/)

 * 1 reply
 * 2 participants
 * Last reply from: [Never Settle](https://wordpress.org/support/users/neversettle/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/another-notice-array-to-string-conversion/#post-6740101)
 * Status: not resolved