Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Shortening an array item

    Hi

    Can anyone help. In a CGI script I have a array item which can be any length.

    It's called $field1[7]

    What do I have to do to make $field1[7] just its first 40 characters ..... (if less than 40, that's fine)

    If anyone could help with a line or two of code, I'd really appreciate it....

    Thanks

    snow

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $field1[7] = substr($field1[7],0,40);

    That takes the first 40 characters of $field1[7] (if they exist)

    Mzzl, Chris

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks .......

    It works great. I appreciate it.

    snow


  •  

    Posting Permissions

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