Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    42

    Unanswered: removing the first 25 chars off a mysql query

    Hi

    I have a rather interesting problem. Im using a program which stores some rubbish in the mysql datase. For example:

    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl {\f0\fnil MS Sans Serif;}}
    \viewkind4\uc1\pard\f0\fs16 4 bedroom detached house *lounge *dining room *cloakroom *bathroom *tandem garage *good sized gardens *parking for several cars *double glazing * central heating
    \par
    \par }

    Is there a way in php that I can take off the first characters and last characters that are not needed.

    Cheers for any advice.

  2. #2
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    The rubbish you refer to is the formatting info for the Rcih Text Format. Perhaps there is some setting on the program you are using to allow the storage of info the plain text rather than rtf.

  3. #3
    Join Date
    Mar 2004
    Posts
    42
    Hey gannet. Ill take a look at the program sometime. I didn't develop the program so have no idea of how it operates. It seems rather silly to me to have that rich text formatting in the database. We have over 1000 columns with that replicated data. What a waste of space.

    CHeers

  4. #4
    Join Date
    Sep 2003
    Location
    So. Cal. USA
    Posts
    142
    Hi, jon... If you're still interested in string chopping in PHP, here's a snippet from the PHP manual about substr().
    --ST


    string substr ( string string, int start [, int length])


    substr() returns the portion of string specified by the start and length parameters.

    If start is non-negative, the returned string will start at the start'th position in string, counting from zero. For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.


    Example 1. Basic substr() usage

    <?php
    $rest = substr("abcdef", 1);****// returns "bcdef"
    $rest = substr("abcdef", 1, 3); // returns "bcd"
    $rest = substr("abcdef", 0, 4); // returns "abcd"
    $rest = substr("abcdef", 0, 8); // returns "abcdef"

  5. #5
    Join Date
    Mar 2004
    Posts
    42
    Arh nice one Steve. Thanks alot. Ill still take a look at the program as its really going to bloat the database. Now ive got something to look up on the php side im happy. Cheers.

Posting Permissions

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