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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:04:47+00:00 2026-05-17T02:04:47+00:00

Hope you are fine. My question : In MYSQL i have a table with

  • 0

Hope you are fine. My question :

In MYSQL i have a table with this type of field

Field Name: TAGS
Value : xavier,celine,marise,leon,john,cathy,polux,maurice


In PHP i do this

$xwords = array();
function array_rpush(&$arr, $item)
{
  $arr = array_pad($arr, -(count($arr) + 1), $item);
}

$tags = requete("SELECT tags FROM tbl_tags LIMIT 1;");
while($dtags = mysql_fetch_assoc($tags)){
  $words .= array_rpush($xwords, $dtags['tags']);
}

// MY ARRAY XWORDS FOR DEBUG
//
// Array ( [0] => xavier, celine, marise, leon, john, cathy, polux, maurice
//

My script need to find the first letter of each word in this list and check if he match with A / B / C (i create an A-Z index page)

// COUNT $XWORDS VALUE
$total = count($xwords);
// total =1
for($i=0; $i < $total; $i++)
{
 $wtags = explode(",",$xwords[$i]);
 // wtags = Array ( [0] => xavier [1] => celine [2] => marise... )
  while (list($idx,$val) = each($wtags)) {
    echo $val{0}."<br>";
    echo substr($val,0,1)."<br>";
  }
}

echo $val{0}."<br>"; OR echo substr($val,0,1)."<br>" give me just x and nothing after (while give me only the first letter for the first record in array… amazing :))

Perhaps you can help me find a solution. 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-05-17T02:04:47+00:00Added an answer on May 17, 2026 at 2:04 am

    The problem with your code is that it generates:

    Array ( [0] => “xavier” [1] => ” celine” [2] => ” marise”… )

    So $val[0] = ” “. Try to trim($val):

    $val = trim($val);
    print $val[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this is the appropriate title for this question. Right now I have
Hope you all are fine and rocking your code editors. My question is how
Hope you are fine. I have to make a Web Project (very simple) I
Hope this question is not stupid since I am an amateur web designer. I
Hope someone could help me with this: I would like to have a column
Hope someone will give me a hand with this problem I have. So here
My question is probably stupid and I hope somebody has succeeded in solving this
This question may have been asked already - but unfortunately, I could not find
I have a table of horses in a classifieds site. The fields in question
Variations of this question have been asked, but not specific to GNU/Linux and C.

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.