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

  • Home
  • SEARCH
  • 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 6696277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:19:20+00:00 2026-05-26T06:19:20+00:00

$arr = explode(‘:’, $row[‘diff’]); echo $arr[0] minutes, $arr[1] seconds; Array is outputting: Array00 hours,

  • 0
$arr = explode(':', $row['diff']);
echo "$arr[0] minutes, $arr[1] seconds";

Array is outputting: Array00 hours, 20 minutes, when it should be outputting: [x] hours, [x] minutes. ONLY IF there are >= 1 hour

This is in the SQL:

TIMEDIFF(now(), listDT) as diff

Is there someway to show, just minutes, if the output is like 0 hours, 22 minutes? Why is Array in front? Can I remove it? How?


Updated

foreach($result as $row)
        { 

        echo "<div class='listing'>";
            print $row['uUName'] . '</strong><br />' .
            '<strong>' . $row['listTitle'] . '</strong><br />' .
            $arr = explode(':', $row['diff']);
            echo "{$arr[0]} minutes, {$arr[1]} seconds";
        echo "</div>";
        }

This STILL outputs: Array00 hours, 31 minutes for example. How do I get it to look like:

00 hours, 31 minutes 

or

(ideally, if hours is 0) 31 minutes

  • 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-26T06:19:21+00:00Added an answer on May 26, 2026 at 6:19 am

    Add braces so that your array vars can be properly interpreted. Like this:

    echo "{$arr[0]} minutes, {$arr[1]} seconds"; 
    

    ETA

    leaving out the parts that equal zero means looping through the array and asking if the array needs to be output or not.

    $map=array_combine(array('hours','minutes','seconds'),$arr);//so each part knows its name
    $filtred=array_filter($map);//get rid of 0 values
    foreach($filtred as $name=>$num){
      echo "$num $name ";
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function get_arr($arr) { unset($arr[0]); } $arr1 = array(1,2); $arr2 = array(1,2); get_arr(&$arr1); get_arr($arr2); echo
echo $_POST['var']; Array(0,Array(0=>;sdfds)),Array(0,Array(1=>;sa;d)),Array(1,Array(0=>;xx;xxx;xxxs)) $new_str = str_replase()),A,))|A,$_POST['var']); $first_arr = explode(|,$new_str); print_r($first_arr); OUPTUT Array ( [0]
I have an array ( arr ) of elements, and a function ( f
You can initialize an array like this: int [ ] arr = { 1,
Hi when I have an array in actionscript var arr : Array = new
var arr = new Array(); arr[0] = 'Departmental News' arr[1] = 'Departmental News' arr[2]
Example for array arr = [a, b, c] # TODO create an alias for
arr[key] = value; where key is a jQuery object and value is an array.
If arr is an array of size 10, in the following code block, how
NSArray* arr = [NSArray array]; int a = MIN([arr count], 1); // 0 correct

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.