Помогите с переменной

Discussion in 'PHP' started by dnnov, 28 Jan 2011.

  1. dnnov

    dnnov New Member

    Joined:
    12 Jun 2010
    Messages:
    0
    Likes Received:
    0
    Reputations:
    0
    Есть группа переменных:

    $a = "blablabla";
    $b = "klaklakla";
    $c = "howhowhow";
    и тд...

    необходимо обрезать переменные и привести их к виду:

    $a ="bla";
    $b = "kla";
    $c = "how";

    т.е обрезать до Х кол-ва символов!
    как это можно реализовать?


    (дайте пример кода)
     
    #1 dnnov, 28 Jan 2011
    Last edited: 28 Jan 2011
  2. IgrikX

    IgrikX New Member

    Joined:
    13 Aug 2009
    Messages:
    114
    Likes Received:
    1
    Reputations:
    -3
    в массив потом 3 символа читать
     
  3. Fepsis

    Fepsis Elder - Старейшина

    Joined:
    17 Sep 2008
    Messages:
    791
    Likes Received:
    391
    Reputations:
    72
    http://ru.php.net/manual/en/function.substr.php

    Там и примеры кода найдёшь...
     
  4. dnnov

    dnnov New Member

    Joined:
    12 Jun 2010
    Messages:
    0
    Likes Received:
    0
    Reputations:
    0
    спасибо! исчерпывающий мануал
     
  5. De-visible

    De-visible [NDC] Network develope c0ders

    Joined:
    6 Jan 2008
    Messages:
    916
    Likes Received:
    550
    Reputations:
    66
    Code:
    count = 3 # сколько символов выводить
    a = "blablablabla"
    print a[:count]
     
    1 person likes this.