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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:33:02+00:00 2026-05-27T21:33:02+00:00

I am retrieving some data from a table in mysql. The values are stored

  • 0

I am retrieving some data from a table in mysql. The values are stored with a | separater
Example:
test 1|test 2|test 4 and so on..
Everything works great except when there are blank entries in the column. I am using the following code.

$groups = explode('|', $row['groups']);
if(count($groups) >0) 
{
   echo 'There are values';

}else{ 
   echo 'No values';
} 

The problem I have is this returns ‘There are values’ even if the column is empty.
Any help would be great appreciated.

  • 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-27T21:33:03+00:00Added an answer on May 27, 2026 at 9:33 pm

    explode

    If delimiter is an empty string (“”), explode() will return FALSE.
    If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned,
    otherwise an array containing string will be returned

    <?php
    $g = "";
    $e = explode('|',$g, -1) ;
    if ($e) print "yes 1"; else print "Non 1";
    
    $g = "";
    $e = explode('|',$g, 1) ;
    if ($e) print "yes 2"; else print "Non 2";
    
    ?>
    
    Non 1
    yes 2
    

    The issue is that your returned array contains a single element that is empty string.

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

Sidebar

Related Questions

For some reason I'm having a problem retrieving data from my database. It leaves
Can anybody help me with retrieving some elements from the following example text: sdfaasdflj
When retrieving a lookup code value from a table, some folks do this... Dim
I am using this sample to decode/encode some data I am retrieving/sending from/to a
I am facing some issues while retrieving data from a doctrine pager object! Let
In my java code,I am retrieving some multibyte data from database and making some
how to cache data source contents? suppose I'm retrieving some records from my sql
So I'm retrieving some JSON data from a website and using the standard urlopen()
One thing I've started doing more often recently is retrieving some data at the
i posted some data using tinymce (in a symfony project).while retrieving back how can

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.