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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:22:28+00:00 2026-06-05T22:22:28+00:00

I have this (I’m only showing three records, there are many, many more) Array

  • 0

I have this (I’m only showing three records, there are many, many more)

Array
(
[0] => Array
    (
        [name] => Johnson, John
        [telephonenumber] => 555.555.555
        [department] => Department A
    )

[1] => Array
    (
        [name] => Johnson, Bill
        [telephonenumber] => 555.555.4444
        [department] => Department B
    )

[2] => Array
    (
        [name] => Johnson, Carry
        [telephonenumber] => 555.555.3333
        [department] => Department C
    )
)

There will be multiple members of Department A, B, etc. and I need to loop through this data and spit out only members of Department A. I have tried:

if ($phoneList['department'] == 'Falmouth') {
    echo $phoneList['name'] . '<br>';
    echo $phoneList['telephonenumber'] . '<br>';
    echo $phoneList['department'] . '<br><br>';
}

But I am getting errors because I think $phoneList['department'] doesn’t exist (shouldn’t be $phoneList[0]['department'])?

Either way, that won’t help… how can I search through all 90 of these arrays and only print out those with Department A status?

$phoneList is the variable being passed to my view (using codeigniter, ldap and php)

  • 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-05T22:22:31+00:00Added an answer on June 5, 2026 at 10:22 pm

    You could use foreach:

    foreach($phoneList as $item)
    {
      if($item['department'] == 'Falmouth')
      {
        echo $phoneList['name'] . '<br>';
        echo $phoneList['telephonenumber'] . '<br>';
        echo $phoneList['department'] . '<br><br>';
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array in PHP: array( [0] => array( 'username' => 'user1' )
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Have this print output from print_r($theobject); SimpleXMLElement Object ( [@attributes] => Array ( [label]
i have this array: Array ( [15] => 13.1 [16] => Mark one answer
Have this objects and table types: CREATE TYPE Person_typ AS OBJECT ( name CHAR(20),
I have this function in my custom dynamic array class that allows the user
Have this scenario: public class Base { public string Name; } public Class ClassA
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in
We have this software that has a webservices component. Now, the administrator of this

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.