Struggling with array and foreach loop

You can get an array with just the numbers by using array_values($your_array); It will return an array with just the numbers. Is this what you need, or a string with a comma separated list of IDs? If that’s the case, use this: implode(“,”,array_values($your_array)); Hope this helps.

How to pass conditional array to wp_localize_script

Ended up with this as the function: // set up the settings for the theme.js function mb_scripts_settings() { // blanks $mb_ajax_form_type = $mb_get_page_slug = $mb_redirect = $mb_redirect_time = $mb_form_disable = $mb_array = ”; // get the form type $mb_ajax_form_type = ( is_front_page() ? ‘change’ : ‘submit’ ); // get the page slug from ID $mb_get_page_slug … Read more

Stuck with a Custom Field Check box Array

It’s a serialized string. Use Unserialize to get an array out of this. Also checkout WP’s maybe_unserialize method. <?php $string = “s:19.a:1:{i:0;s2”; //Using WP maybe_unserialize $result1 = maybe_unserialize($string); //Using PHP unserialize $result2 = unserialize($string); echo “<pre>”; print_r($result1); print_r($result2) echo “</pre>”; ?> $result will hold what you want.

Echoing a variable inside a function

Use the Settings API. A look at my latest plugin may help you to understand how to register a save function for your fields. Most relevant excerpt: /** * Register custom settings for the fields. * * @see save_settings() * @see print_input_field() * @return void */ public function add_contact_fields() { register_setting( ‘general’, $this->option_name, array ( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)