0

I want to get some page/post elements settings outside Elementor.

$data_wp =  get_post_meta(830,'_elementor_data',true);
$data_wp_array =  json_decode($data_wp, true);

But now I can not return value from recursive function in PHP?

function find_elementor_setting_from_wordpress_post_meta( $array, $serch){
  foreach ($array as $val){
    if(is_array($val)){
      find_elementor_setting_from_wordpress_post_meta($val,$serch);
    }elseif(is_string($val)&& $val=== $serch){
      echo '<h2>Ich Bin DA</h2>';
      return $array;
    }
  }
};

$echt = find_elementor_setting_from_wordpress_post_meta($data_wp_array,'2d948c5');
var_dump($echt); // <--- retunr NULL :)

Answer :

function find_elementor_setting_from_wordpress_post_meta( $array, $serch){
  foreach ($array as $val){

    if(is_string($val)&& $val== $serch){
      return $array;
    }

    if (is_array($val)) {
      $result = find_elementor_setting_from_wordpress_post_meta($val,$serch);
      if ($result !== null) {
        return $result;
      }
    }

  }
};

0 Answers0