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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:14:36+00:00 2026-05-24T00:14:36+00:00

I have the following code $getchats = $api->call(getLatestChats); echo ‘<pre>’; print_r(array_values($getchats)); echo ‘</pre>’; which

  • 0

I have the following code

$getchats = $api->call("getLatestChats");
echo '<pre>';
print_r(array_values($getchats));
echo '</pre>';

which gives me the following results..

Array
(
[0] => success
[1] => getLatestChats
[2] => Array
    (
        [0] => Array
            (
                [message] => type /ch g
                [time] => 1311806596
                [player] => mattsnod
            )

        [1] => Array
            (
                [message] => im good
                [time] => 1311806601
                [player] => lueroi01
            )

        [2] => Array
            (
                [message] => im good
                [time] => 1311806606
                [player] => lueroi01
            )

I know I can use

print_r(var_dump($getchats));

to get it into a PHP array, but im having trouble figuring out how to work with this data better.

in the php array, its like this

array(3) {
  ["result"]=>
  string(7) "success"
  ["source"]=>
  string(14) "getLatestChats"
  ["success"]=>
  array(50) {
[0]=>
array(3) {
  ["message"]=>
  string(4) "yes?"
  ["time"]=>
  int(1311806791)
  ["player"]=>
  string(8) "mattsnod"
}
[1]=>
array(3) {
  ["message"]=>
  string(10) "um hold on"
  ["time"]=>
  int(1311806796)
  ["player"]=>
  string(8) "mattsnod"
}

This is a very general question, but how could I use a foreach or while to work with this data as Im not having much luck. Im sure Im overlooking something, but my head is hurting now. Ive been googling and reading all morning.

after some more playing, this is close to what im wanting..

foreach($getchats as $chat_on=>$data){
//echo "<b>$chat_on</b><br>";
foreach($data as $key=>$value){
    //echo "$key - $value<br>";
    foreach($value as $key2=>$value2){
        echo "$key2 - $value2<br>";

    }
}
}

now to figure out how to manipulate these individually or call as $key2[message] so that i can convert the time stamp and format differently.

message – rlly?
time – 1311809089
player – m0terb0nd

Ultimately, this accomplished what I wanted..

foreach($getchats as $chat_on=>$data){
    foreach($data as $key=>$value){
            $date = date("h:i a", $value['time']);
            echo "($date) $value[player]: $value[message]<BR><BR>";
    }
}
  • 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-24T00:14:37+00:00Added an answer on May 24, 2026 at 12:14 am
    foreach($getchats->success as $chat) {
       echo $chat['message'] . "<br>";
       echo $chat['time'] . "<br>";
       echo $chat['player'] . "<br>";    
    }
    

    Some reference on foreach can be found here – http://www.php.net/manual/en/control-structures.foreach.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following Code Block Which I tried to optimize in the Optimized section
i have following code in my php jquery call... <object type=application/x-shockwave-flash data=mysounds/player.swf id=audioplayer1 height=1
I have following code which works fine in firefox and ie 8, but in
I have following code which add BackButton on my view's navigation item's tabbar. It
I have following code: $boxId = 1; $explainationBox='<input type=button id=<?php echo $boxId; ?> value=send
I have following code which works fine in iPhone application but in iPad I
i have following code in which, i am fetching the data from the sqlite
I have following code: VAR1= ANOTHER_VAR=$VAR1/path/to/file ANOTHER_VAR_2=$VAR1/path/to/another/file ... # getopts which reads params from
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following code in my application: // to set tip - photo in

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.