Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    <prantik>
    <prantik>'s Avatar
    Guest

    php pattern check code wanted? 10pts for best answer?

    i want a code than checks the pattern and tell me if there a alphabet or alpha numeric is in the whole string,
    i have done this:
    <?
    if(0 == preg_match_all ("|[0123456789_]|", "".$subject."", $string_out_array))
    {
    echo "only numeric allowed";

    }
    else
    {
    echo "done";
    }

    ?>

    this works fine if i enter a alphabet before a numeric I.e, a11(output "only numeric allowed") or only numeric I.e, 11(output "done") but not whens i enter a alphabet after the numeric I.e, 11a (output "done") but the output should be" only numeric allowed".

    in short i want only numeric tobe entered,if any other character is entered then a error message should be displayed and vise-verse..please provide the code.

  2. #2
    Pete S's Avatar
    Real Member

    Status
    Offline
    Join Date
    Sep 2009
    Posts
    93
    Downloads
    0
    Uploads
    0
    you're looking to start with numbers only, so your regular expression is wrong

    try ^(\d|[_])*$

 

 

Quick Reply Quick Reply

Click here to log in


In what corner do we have Search box?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP Comment Code Check?
    By Micro Sniff in forum Discuss PHP
    Replies: 0
    Last Post: 10-18-2010, 03:29 AM
  2. Replies: 2
    Last Post: 09-10-2009, 08:37 AM
  3. Is there a website that can check php code?
    By andy m in forum Discuss PHP
    Replies: 0
    Last Post: 03-14-2009, 06:26 PM
  4. Replies: 1
    Last Post: 01-18-2009, 11:09 PM
  5. PHP/MySQL help! Immediate 10pts for best answer!?
    By skinnypspplayer in forum Discuss PHP
    Replies: 1
    Last Post: 12-12-2008, 04:35 PM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •