Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:10:05+00:00 2026-06-07T05:10:05+00:00

I have a slider for news items and doing a loop to get post

  • 0

I have a slider for news items and doing a loop to get post info for each. Works fine but I am stuck with one paramater that is returned by json and I loop trough it again . the $xtras parameter returns some additional values one of them is additional intro text. I need to check if this value isset otherwise I need to return default intro text.

problem I have is that if $xtra_values->id 44 does not exists I get the intro text from previous post instead that post $post['intro']

$xtras returns stdClass Object like this

stdClass Object
(
    [id] => 1
    [value] => 38
)
stdClass Object
(
    [id] => 28
    [value] => 1
)
stdClass Object
(
    [id] => 44
    [value] => This is extra intro text
)

and this is my loop

foreach ($post_array as $key=> $posts){

    $xtras  = json_decode($posts['xtra']);

     foreach($xtras as $key=> $xtra_values){

        if($xtra_values->id == 44){
           $intro_text = $xtra_values->value;
        }else{
           $intro_text = $post['intro'];
        }     

     }




      echo $post['title'];.'<br />';
      echo $intro_text;
}

Any help is appreciated. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:10:06+00:00Added an answer on June 7, 2026 at 5:10 am

    foreach ($post_array as $key=> $posts){

    $xtras  = json_decode($posts['xtra']);
    $intro_text = null;
    
    
     foreach($xtras as $key=> $xtra_values){
    
        if($xtra_values->id == 44){
           $intro_text = $xtra_values->value;
        }     
    
     }
    if($intro_text == null){
           $intro_text = $post['intro'];
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slider I've made, the slider part works correctly, but I'm trying
I have a news slider for my site that I'd like to use but
I have a slider made with jQuery UI, which works completely fine, except that
I have Slider,which works perfect. But what i am trying to do is, for
I have an slider animation but on clX.click event #close div hides before it
I have a slider, whose velocity I calculate via the difference between positions each
I have one slider to select time range, from 1 (,2,3,..) day (,weeks,months,..) ago
I have custom slider sitting at the top of my page but I'm having
I just can't get this right. I have a slider to increase my JPanel's
So I have a list of news items that have AJAX controls to create,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.