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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:13:11+00:00 2026-06-15T05:13:11+00:00

Hi all i’m a bit stuck and need some help. I have a query

  • 0

Hi all i’m a bit stuck and need some help.
I have a query which returns the following

Array
(
[0] => stdClass Object
    (
        [id] => 1
        [username] => Joe Blogs
        [user_number] => JB222
        [email] => jb@kemail.com
        [job_title] => Teacher
        [contractor] => Direct Hire
        [campus] => Male Humanities
        [role] => Teacher
        [section_number] => 11111 | 213312 | 232121 | 432231
        [stid] => 89,91,95,94
        [classroom] => 2621,1329,1428,3123
        [subject] => English | Physics | English | Maths
    )

)

I need to be able to break this apart so i can loop through the stid,section,classroom and subjects as part of a nested loop.
Id like to join the section and classroom together and keep the stid separate so i can use it in a link. I also want to keep the class separate.

                                     -----------------------------------------------
                                     |    sections    |  classroom   |   Teacher    |
                                     -----------------------------------------------
this would be a link with stid 89 -> | English 11111  |    2621      |  Joe Blogs   |
this would be a link with stid 91 -> | Physics 213312 |    1329      |              |
                                     | English 232121 |    1428      |              |
                                     | Maths   432231 |    3123      |              |
                                     -----------------------------------------------

I’ve tried different things and can’t get them to work. Below is what i tried but i could work out how to get each stid as a value in the link. I also tried to to put an if statement to say N/A if the class was empty but that wasn’t working either.

OLD CODE

<ul>

@if ( empty($teacher->subject) )
N/A 
@else   
 <?php 
     $sections = explode(' | ',$teacher->section_number );
 $subjects = explode(' | ',$teacher->subject);  
 $data = array_combine($sections,$subjects); ?>

      @foreach ( $data as $section=>$class)     
      <li>{{ $section . " - " .$class }}</li>
      @endforeach

@endif

</ul>
</td>
<td> 
<ul>

 <?php $classrooms = explode(',',$teacher->classroom); ?>
@foreach ( $classrooms as $room)    
    <li>{{ $room }}</li>
@endforeach

</ul>

Any help would be appreciated. especially with some explanation as to where i went wrong.
Thanks

  • 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-15T05:13:12+00:00Added an answer on June 15, 2026 at 5:13 am
    /* NEEDED FOR TESTING 
    $teacher = new StdClass;
    $teacher->id = 1;
    $teacher->username = 'Joe Blogs';
    $teacher->user_number = 'JB222';
    $teacher->email = 'jb@jbkemail.com';
    $teacher->job_title = 'Teacher';
    $teacher->contractor = 'Direct Hire';
    $teacher->campus = 'Male Humanities';
    $teacher->role = 'Teacher';
    $teacher->section_number = '11111 | 213312 | 232121 | 432231';
    $teacher->stid = '89,91,95,94';
    $teacher->classroom = '2621,1329,1428,3123';
    $teacher->subject = 'English | Physics | English | Maths';
    */
    
    $stid = explode(",",$teacher->stid);
    $classroom = explode(",",$teacher->classroom);
    $subject = explode(" | ",$teacher->subject);
    
    foreach($stid as $k=>$s){
        echo $subject[$k].' '.$classroom[$k].' '.$s.'<br>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, Say I have the following bit of code: select: function(start, end, allDay) {
All - Need some insight into this issue. I have created a sample project
All, I have the following Append which I am performing when I am producing
All, If I run a query like the following: $qry = Select wrong_column from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I have the following code: $fetch = mysql_query(SELECT * FROM calendar_events where event_status='booked'
All, We could really do with some advice from SVG gurus. WHAT WE HAVE:
All, I have a shell script on Mac OS X which uses the mdls
All, I have some script tags that are not working in Wordpress. If I
I have a text area in my form which accepts all possible characters from

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.