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 6063981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:13:48+00:00 2026-05-23T09:13:48+00:00

I am trying to reference an array through a function I am calling $bio[‘results’]

  • 0

I am trying to reference an array through a function I am calling

$bio['results'] = $db->query(sprintf('SELECT * FROM `athlete_bio_results` WHERE `PersonID` = %d ORDER BY `athlete_bio_results`.`Type` DESC, `athlete_bio_results`.`Date` DESC;', $id));

    $smarty->assign(value($params, 'to', 'athlete'), $bio);

In my view I am referencing through a foreach loop some of the fields through this array.

How would I reference a field outside of this foreach loop for checking..For instance in the foreach loop I can go {$result.Type) which will bring up everything in the db under that field. I want to check for a certain type before the foreach loop. My problem is referencing that piece of data outside the foreach loop. How would I achieve this? Thanks!

{if $athlete.results['Type'] == 'National'} <---- This is not working for me.
    {foreach $athlete.results as $result}
        {$result.Date|substr:0:-6} 
        {$result.Event} - 
        {$result.Result}
            {if $result.Junior == 'no' || $result.Junior == ''}
            {else}
                {'(Jr. Div.)'}
            {/if}
        <br />
    {/foreach}
{/if}

EDIT

This is the code that works

{foreach $athlete.results as $result}
    {if $result['Type'] == 'National'}
        {$result.Date|substr:0:-6} 
        {$result.Event} - 
        {$result.Result}
            {if $result.Junior == 'no' || $result.Junior == ''}
            {else}
                {'(Jr. Div.)'}
            {/if}
    <br />
    {/if}
{/foreach}  

Thanks for your help in guiding me to the right solution 🙂

  • 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-05-23T09:13:49+00:00Added an answer on May 23, 2026 at 9:13 am

    Since you’re accessing the first element of the array, use the key [0]:

    {if $athlete.results[0]['Type'] == 'National'}
    

    Actually I’m not certain that will work. If it doesn’t, try this syntax instead.

    {if $athlete.results[0].Type == 'National'}
    

    EDIT
    Should you be checking Type inside the foreach?

    {foreach $athlete.results as $result}
      {* Check inside the loop... *}
      {if $result['Type'] == 'National'}
        {$result.Date|substr:0:-6} 
        {$result.Event} - 
        {$result.Result}
            {if $result.Junior == 'no' || $result.Junior == ''}
            {else}
                {'(Jr. Div.)'}
            {/if}
        <br />
      {/if}
    {/foreach}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to pass an array of values from PHP function to Javascript. Not
From my understanding Sizzle returns an array of objects (DOMElements), I am trying to
I'm trying to loop through an array fSel.sI, and based on the data inside,
Im trying to create a conditional statement that iterates through an array of nodes
I'm trying to parse a JSON string into an array reference: my $str =
I'm using Firefox 3.5.7 and within Firebug I'm trying to test the array.reduceRight function,
I am trying to reference the jQuery library in my master page like so:
We are trying to reference a certificate for a client endpoint configuration in our
I am trying to reference some child entities with part of the parents composite
In the below code, i am trying to reference an external .dll, which creates

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.