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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:01:53+00:00 2026-05-18T07:01:53+00:00

I came across this php ucfirst() to make uppercase the first character of each

  • 0

I came across this php ucfirst() to make uppercase the first character of each word in a string.

$foo = 'hello world!';
$foo = ucfirst($foo); 

but how can I use use regular expression and preg_match() to check, then display the error message?

if (preg_match('/\b\p{Ll}/', $mem_titlename))
{
   $error = true;
   echo '<error elementid="mem_titlename" message="TITLE - please use uppercase for each word."/>';
}

not sure what that expression means in the example above but I got it from somewhere which does the same job as ucfirst()…

  • 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-18T07:01:54+00:00Added an answer on May 18, 2026 at 7:01 am

    Why use a regular expression? It seems unnecessary if ucwords() does what you want. If so, just the following:

    if (ucwords($mem_titlename) == $mem_titlename) {
       $error = true;
       echo '<error elementid="mem_titlename" message="TITLE - please use uppercase for each word."/>';
    }
    

    Also note that ucwords() does what you describe, not ucfirst(). http://www.php.net/manual/en/function.ucwords.php

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

Sidebar

Related Questions

Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I recently came across this line in a PHP script: $_REQUEST['start_date']=$date; Is it allowed
I've been developing with PHP for some years now, and recently came across this
I came across this problem: http://www.iarcs.org.in/inoi/contests/oct2005/Advanced-2.php The problem basically is about graphs. You are
I was reading a blog post when I came across this code: <?php include_once
Hello my fellow Stackoverflownians :), I just came across this thing called Zend. And
I came across this script at http://www.php.net/manual/en/function.str-split.php#78040 /** Returns a formatted string based on
I came across this conditional in a function I'm working with: <?php $thisweek =
I wanted to implement Comet in PHP and came across this page: http://www.zeitoun.net/articles/comet_and_php/start The
I came across this ticket on github: https://github.com/bobthecow/mustache.php/issues/34#issuecomment-805892 The comment states: Note that use

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.