1st 5 Chars - 1st 5 chars from the word

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

1st 5 Chars - 1st 5 chars from the word

ivanc081
Can someone tell me, how to get
first 5 characters from the some word i have i my database (mysql)
example:
$word = VerylongLonglognword_or_sentence;
$short_w= veryl...;

Reply

miCRoSCoPiC^eaRthLinG
QUOTE(ivanc081 @ Mar 9 2005, 04:31 PM)
Can someone tell me, how to get
first 5 characters from the some word i have i my database (mysql)
example:
$word = VerylongLonglognword_or_sentence;
$short_w= veryl...;
*



I'm going to use the variables that you've used. Say your $word contains the very long word. Now:

CODE

$short_w = substr ( $word, 0, 5 );


This should extract the first 5 characters from your $word and store it in $short_w. This is assuming you are using PHP with MySQL. If you want a little more explanatin - the substr function extracts a substring from your string based on the parameters provided to it. General form is: susbstr ( LargeString, StartPosition, LengthOfSubString ) - this extracts a string of length LengthOfSubString starting at position StartPosition from your original string LargeString.

Hope this helps. smile.gif

 

 

 


Reply

ivanc081
tnx, its working!

Reply

Spectre
You can also use $variable[length], eg. $variable[4]. Remember that the starting position is 0, not 1, so this would extract the first 5 characters.

Reply

Spectre
Argh, what am I thinking? That would select the character, not the first 5 characters. It's 3:00am, so you'll have to excuse my incoherence.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : 1st, 5, chars, 1st, 5, chars, word

  1. Mac To Read Microsoft Word
    (3)
  2. Ms Word Document Sample Required
    I need an MS Word document as a sample (0)
    I am writing a small script, and need an MS Word document that contains an email address, or a list
    of several email addy's. They do not need to be "actual" addresses, just formatted as email
    addies to test the script and how it handles them. I will NOT be using or selling the addresses.
    Guaranteed. Only the formatting of the address is being tested, not the address themselves. If you
    have, (or will create), a document, please forward a PM and I will send instructions to you about
    how to forward it to me. Thanks for reading this request.....
  3. Text Editors Vs Word Processors
    (6)
    There are many differences between text editor and a word processor. One of those differences is
    that most text editors are universal in editing any text based documents, while word processors can
    only edit certain types of files like Open Office. So, because of that universal editing more text
    editors are very basic and so they carry few commands, such as copy and paste and being able to save
    the document. While word processors have hundreds of commands and come with many other features
    such as templates, thesaurus, spell checker etc etc. So with all those features....
  4. Eat The Word! Be Fruitful
    Let us be practicing Christians. (0)
    Lord Jesus mentions about four categories of people. The first group of people hears the Word of God
    very casually. In today’s context, people hear various preachers through the TV or radio. They do
    not pay attention to it many times. Satan takes away from their mind what they listened casually.
    The second group of people listens to the Word of God joyfully. They appreciate the speaker and show
    interest in the style and language. But they do not meditate upon them and fix them in their hearts.
    So when problems come, they get disturbed, criticize the preacher or the Word....
  5. Compare Char's In Words
    (4)
    I've got an exercise given out by my tutor and I'm basically stumped. Part of it is to
    compare words then work out the shortest number of characters that is required to uniquely identify
    them. For example.. cat dog horse Out of this group of only the first letters can be used c, d, h
    where as other groups like ant and antelope would require ant, ante. Given this problem I've
    been trying to figure out how to do this and so far I'm manage to split each word into char
    arrays but when I try to compare them with other copies for a match I get two errors, Ei....
  6. Word Games
    bookworm, scrabulous,etc (0)
    is there anyone who love word games here?? personally am addicted to the scrabulous site... fans of
    scrabble, check it out scrabulous.com meet you there /smile.gif" style="vertical-align:middle"
    emoid=":)" border="0" alt="smile.gif" />....
  7. How Did You Hear About This Forum
    word (639)
    Hi! friends, we are all here... but how did we reach here? Lets take a poll, may be this info
    will be useful to the admins also, in shaping their policies... So let's start!
    Googlue! Could you also visit my site and comment on that here? I found out in another
    forum. When I was disgusted with shyper.com, I started searching and reached post2host.com. That
    sucks... and is anyway down! Somebody had mentioned this site there.. and goog lord.. I am here.
    LOL /rolleyes.gif' border='0' style='vertical-align:middle' alt='rolleyes.gif' /> ____....
  8. Opening Large Programs With Ms Word
    HAHA! (0)
    Step 1 --> Open up microsoft word if you have it. If you don't.... try another word
    processing program... or else your screwed... sorry. Step 2 --> Go to open. Step 3 -->
    Enable all files for opening. (Right underneath where you would type a file name) Step 4 -->
    Select something gigantic like google earth, etc... Step 5 --> Wait a minute or two... you
    have gigantic hunred thousand page documents! Well... nothing you can really read or understand
    but whatever.... (If you have autocad or rhino, or bryce, etc... you can actually reach t....
  9. Php Word Filter
    Have you accidently sworn on your site? Or do you want to keep visitor (9)
    This is pretty simple but very useful if you don't want people to swear. We will be using
    str_replace for this. CODE <?php str_replace ("curseword,
    "replacemet"); ?> Thats pretty simple, just fill in the curse word and the
    replacement, and then repeat... heres what it would look like full size: CODE <?php
    str_replace("swear", "replacement"); str_replace("swear",
    "replacement"); str_replace("swear", "replacement");
    str_replace("swear", "....
  10. One Word Equals 10 Grains Of Rice
    freerice.com (30)
    http://freerice.com/ Feeding the hungry is as simple as a click away. 10 grains of rice per word
    may not seem like much, but the site donates based on revenue brought in by its advertisements.
    Meaning, more visitors and players can increase the amount of grains per word. Also, getting over
    5,000 grains a day is not hard to do. Kindly join in on the fun! /xd.gif"
    style="vertical-align:middle" emoid=":XD:" border="0" alt="xd.gif" />....
  11. Dog The Bounty Hunter And The N Word
    Dog is Lying His Butt Off. (12)
    WHEN IT COMES TO (RACIST) DOG THE BOUNTY HUNTER, DON'T BELIEVE THE HYPE!
    Yo. I use the so-called "N-Word" in MY daily life. I'm one of those brothas that Bill Cosby
    and Oprah despise because I use the word without shame. I use it as an affectionate term or an
    all-descriptive term that is interchangeable with the word "man". This is the common affectionate
    or all-inclusive use of the word in the 'hood, or, truthfully, throughout black life. I use the
    form of the word that is spelled with an "A" at the end, and not the form that ends....
  12. 3 Sentence Game
    Modified the '3 Word Game' (1)
    Ok, to avoid breaching Trap17 Rules I have modified a game where each person says 3 words so that
    each person says 3 sentences. The sentences should make sense when joined with the sentences above
    Here are some examples: This is Right: ""Hello Springfield, eat my shorts. I walk down the stairs. I
    say "Hi MOM"" ""My MOM says "Hi BART". I continue Walking. I go to my DAD, I say "Hi DAD"" And this
    is WRONG: ""Hello Springfield, eat my shorts. I walk down the stairs. I say "Hi MOM"" ""I punch my
    MOM in the face. I go outside and start re-enacting the 'TEXAS CHAINSAW MAS....
  13. Word 2007 Annoyance Hehe
    (4)
    ok i work part time for this internet caffe... the amount of customers asking about their word
    documents is shocking... we run msoffice 2000 on our computers and about 80 percent of our customers
    comes in with .docx work ... i spent alot of time explaining and guiding those coming with their
    laptop how to save them in 97-2003 compatible mode... does the docx have any advantage over the
    old .doc?....
  14. Questions Regarding Word Press
    (1)
    Hello All. I am new to the web site arena. I am hoping to use trap.17 to create one of a few types
    of sites. I am uncertain as to which I will attempt to launch first. I would like to create a
    site that consists of several forums that will be geared towards medical transcription. I would
    also like to create a celeb news site. And, eventually, I would also like to set up a site for my
    10 year old son for him to post whatever he wants. He is interested in news writing already. My
    question is...is Word Press, in conjunction with trap17 going to be enough for me to....
  15. Microsoft Word For Free?
    Is that possible? (18)
    When I got my PC for dell It came with a program called Word Perfect. It was awful! So I
    uninstalled it. But is there any way I can still get Microsoft word? I don't want to do anything
    against Microsoft. So is there a way to get it?....
  16. Firefox Dictionary Word Edit
    Oops! Accidentally selected "Save to dictionary" on a mis- (3)
    So I've done this twice now. If I keep it up, I'll never find another typo or misspelled
    word when I'm going through searching for them. When I right-clicked on the wrongly spelled word
    I accidentally clicked on the "save to dictionary" choice instead of the corrected word when it came
    up. Now, how do I go in and find that new addition to my dictionary and delete it? I'm using the
    latest version of OSX for Mac, by the way. I have a feeling if I go searching through the "library"
    file under FF, I might find the answer and if that's the case, I'll p....
  17. Word Of The Moment
    (1)
    Select a word. Provide a definition, either one you find by looking it up or even better, write one
    yourself. Then provide an example of the word in use. Talk about what the word means to you and how
    you have used it. Communication - an interaction between two or more participants in which there is
    an exchange of thoughts, ideas, feelings, etc. Trap17 is an excellent place to practice
    communication. Communication is a way for information to be exchanged. Good communication is a
    necessary part of effective relationships. There is both verbal and non-verbal communication....
  18. The Three Word Story 2
    (0)
    I saw a bit of a flaw in the last 3 word story, so here's a little "rule" for this one: When
    ever a user adds his/her 3 words, said user should copy and paste the entire story into their post,
    as to help eliminate the need to have to read through pages and pages, just to see the entire story.
    Simple enough?....
  19. Direct Mp3 Joiner
    Useless. That's the only word I need to say. (3)
    Direct MP3 Joiner This thing here is seriously a waste of time, what it does? It just joins MP3s
    and nothing else, you can even do that with a open-source and free software like Audacity, but the
    only thing is that Audacity is a little bit complicated than this. This software is 7 year olds who
    can read English, differentiate buttons and then just want to merge MP3s together. The interface is
    damn simple and you actually don't need to even look as the main application screen is
    moderately smaller in size than most of the MP3 editing softwares. One feature that is....
  20. Help -- The Word Is Out -- Major Problem
    This thing is about to spread across the whole school! (11)
    Some people may of heard about a earlier topic that I started but this is way bigger then that!
    I need some serious help! /sad.gif" style="vertical-align:middle" emoid=":(" border="0"
    alt="sad.gif" /> My cousin Joelle me and her go to the same school and she told me she was Bi. So I
    know but now she told someone else on the activity bus, The person she told told someone else who
    told someone else and so on and so on. So now so many people are going to know and I have no idea
    what to do! Because five people came to me in lunch about fifteen minutes ago so no....
  21. Highlight A Word In Javascript. Help!
    BBCode (2)
    Hi, I'm making a forum right now, and i'm having some trouble with BBCodes. I want it so
    when they click a button it will add the bbcode and highlight (or place the cursor between) the
    code . Let me clarify, I want a button to be clicked, it adds code to the textarea and places the
    cursor between the tags. Example: CODE [b] (cursor here)  [/b]
    [b] | [/b] The cursor is between the two tags. I REALLY appreciate it, i've
    search so long with no luck.....
  22. A Quick Guide To Creating A 'blog' Website
    I use the term 'blog' in the loosest sense of the word (1)
    Hello all, first post here, nice idea you've got going with the whole credit thing /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> So i thought i'd do my
    bit and write up a quick tutorial on what i've found with my time on the net. Before we start,
    i'd just like to say that when i say 'blog', dont think of a site where all you can do
    is type up your life. No. What I mean is intergrating a program into your site that allows you to
    post news with ease while still still being able to keep the site open to other t....
  23. Pwoak/puoak/pwoaka
    Its not a word but i think it should be don't you? (3)
    This really funny dude i know made up this word pwoak/pwoaka/puoak and it's really cool and i
    think it should be made into a word but being the bright thing i am i don't know how any way it
    can mean anything it can mean fish it can mean.... stuff any way its an expression pronounced pwak....
  24. Microsoft Word Trick
    (13)
    Open Microsoft Word 2000, XP, 2003 or 2007 and type =rand(200,99) this will create 567 pages of
    text. Is this a flaw or cheat in the software.....
  25. Word Clouds
    (0)
    Have you guys heard of linksizzler.com ? joel Comm came up with this and made a load of money with
    the site 500words.com . Just wondering what you guys think of the concept. There are thousands of
    word clouds sites coming up. Do you think putting up a site like this is still a good idea?....
  26. Microsoft Word
    (3)
    Does anyboidy know if Microsoft WOrd is avilablke to downlaod or can you send me it via email if you
    have it please because I am in desperate need for it as I have lots of important documentations to
    write out and I can;t use any other programme apart from that.....
  27. Simple Machine Forum Link Bbcode Help
    I linked some of my word in the topic but... (5)
    I am in trouble , in a lot of topics I typed a link lead to another site with the right format
    but when I click on the , it change to a blank page , what 's wrong ? If I just put the mouse
    over the word I linked , it says at the bottom left of Internet Explorer http://mysite.com/forum
    and then I click it , a blank white page showed up. What should I do now. I putted a Link in the
    NEWS but it goes to the same problem. Thank you very much. Topic title modified. Topic moved. ....
  28. Never Said A Word To Her
    HELP (8)
    I'm a junior, 16. There is a girl, that I haven't spoken to, ever, She's a Freshman,
    probably 14 or 15. I can't explain why, but I have been consatntly thinking about asking her on
    a date for the past few days. My only concern is, what the heck am I supposed to do? Should I just
    randomly talk to her, should I just walk up, introduce myself, and ask her? I don't wanna sound
    creepy, and have it be completely random. Anyone have any advice?....
  29. Get The Word Out - Google Talk
    (13)
    I think AIM is the most popular IMing service followed by MSN messanger. Google Talk is basically a
    dead messanger and no one uses it. If anyone wants to help I say we get the word of this out to all
    our friends and to forums. I also suggest we contact PHP, IPB, IF, and other boards to add a GT
    button to go along with AIM, MSN, YIM, ICQ, and Email. Also if someone could make a Get Google Talk
    userbar it would be a good way to get the word out.....
  30. Word Wrap Text In Div.
    (16)
    i use 2 div's for the page layout. One for navigation and one for the contents. html Code:
    Original - html Code: CODE    <div width="10%" style="position:
    absolute; left: 2%;">
    bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb </div> <div
    width="86%" style="position: absolute; left: 14%;"> bbbb </div>
    But now the b's wont stay within their div-element. I want lines that doesnt fit on one line
    within the divto wrap to the next line. How can i do this?....

    1. Looking for 1st, 5, chars, 1st, 5, chars, word

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for 1st, 5, chars, 1st, 5, chars, word

*MORE FROM TRAP17.COM*
advertisement



1st 5 Chars - 1st 5 chars from the word



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE