+
1 2 12
1 10 16

: PHP

  1. #1
    WindForce       WindForce
    05.01.2007
    .
    87
    ()
    0
    : 0 (: 0).

     PHP

    $a :
    'text0','text1','text2'
    $b (print_r($b)):
    Array
    (
    [0] => 'text0'
    [1] => 'text1'
    [2] => 'text2'
    )
    : ?
    ( ), "','" substr() .
    . .

  2. #2
    1nsk   Group alfa ()     alfa
    14.05.2006
    1nsk.ru
    3,736
    ()
    4
    : 1 (: 1).

    , :
    :
    var_dump($a);
    13
    :
    $a="'text0','text1','text2'";
    $b = preg_split('/[\s,]+/', $a);
    print_r($b);
    :
    Array
    (
        [0] => 'text0'
        [1] => 'text1'
        [2] => 'text2'
    )
    53
    -?
    -

  3. #3
    Mirage     Mirage       Mirage
    14.01.2007
    1,252
    ()
    0
    : 0 (: 0).

    10 "'string1','string2','string3'" array('string1', 'string2', 'string3'):

    :
    $a="'string1', 'string2', 'string3'";
    preg_match_all("/\'(.*)\'/U", $a, $m);
    $b = $m[1];
    var_dump($b);
    :

    :
    array(3) { [0]=> string(7) "string1" [1]=> string(7) "string2" [2]=> string(7) "string3" }
    1
    alfa,
    , .
    . .
    :
    : , ?
    :
    , , .

  4. #4
    themylogin       themylogin
    31.03.2007
    1,178
    ()
    0
    : 0 (: 0).

    ,
    PHP :
    $b explode(','$a); 
    When it rains, it pours. .

  5. #5
    1nsk   Group alfa ()     alfa
    14.05.2006
    1nsk.ru
    3,736
    ()
    4
    : 1 (: 1).

    themylogin, preg_match , '
    -

  6. #6
    themylogin       themylogin
    31.03.2007
    1,178
    ()
    0
    : 0 (: 0).

    ^_^
    PHP :
    $b explode(','$a);
    array_walk($bcreate_function('&$val, $key''$val = trim($val, "\'");')); 
    themylogin; 15.07.2007 21:44.
    When it rains, it pours. .

  7. #7
    Mirage     Mirage       Mirage
    14.01.2007
    1,252
    ()
    0
    : 0 (: 0).

    , , name input "b[]".

    15
    , :

    :

    :
    $a="'string1', 'string2', 'string3'";
    $s = microtime(1);
    preg_match_all("/\'(.*)\'/U", $a, $m);
    $b = $m[1];
    printf("preg_match_all   %0.8f\n", microtime(1)-$s);
    $s = microtime(1);
    $b = explode(',', $a);
    array_walk($b, create_function('&$val, $key', '$val = trim($val, "\'");')); 
    printf("explode  array_walk   %0.8f\n", microtime(1)-$s);
    5 , :

    P - preg_match_all
    E - explode & array_walk

    1. P: 0.00007391 E: 0.00008297
    2. P: 0.00007391 E: 0.00009394
    3. P: 0.00007606 E: 0.00009394
    4. P: 0.00007415 E: 0.00012803
    5. P: 0.00007319 E: 0.00008297

    , , split explode , , ',', "" ', ' .

    2
    . code ?
    . .
    :
    : , ?
    :
    , , .

  8. #8
    themylogin       themylogin
    31.03.2007
    1,178
    ()
    0
    : 0 (: 0).

    :
    themylogin@themylogin:~$ php mir.php
    	preg_match_all   0.00013185
    	explode  array_walk   0.00012183
    themylogin@themylogin:~$ php mir.php
    	preg_match_all   0.00013518
    	explode  array_walk   0.00012183
    themylogin@themylogin:~$ php mir.php
    	preg_match_all   0.00013304
    	explode  array_walk   0.00014400
    themylogin@themylogin:~$ php mir.php
    	preg_match_all   0.00013399
    	explode  array_walk   0.00011992
    8-)
    When it rains, it pours. .

  9. #9
    Mirage     Mirage       Mirage
    14.01.2007
    1,252
    ()
    0
    : 0 (: 0).

    , windows, , preg , .

    1
    -
    . .
    :
    : , ?
    :
    , , .

  10. #10
    themylogin       themylogin
    31.03.2007
    1,178
    ()
    0
    : 0 (: 0).

    preg
    ereg,
    When it rains, it pours. .