• 25-01-2021, 18:50:13
    #1
    Merhaba arkadaşlar

    test::::deneme
    test1::::deneme1
    test2::::deneme2
    test3::::deneme3
    test4::::deneme4


    şöyle bir içeriğim var. sadece test - test1... leri almak istiyorum. bunu nasıl yapabilirim.
  • 25-01-2021, 18:54:43
    #2
    PHP explode ile yapabilirsin
    Örnek makale linki bırakıyorum

    https://www.webcebir.com/149-php-exp...lme-dersi.html
  • 25-01-2021, 18:58:51
    #3
    $arr = explode("::::", $data);
    echo $arr[0];
  • 25-01-2021, 18:59:14
    #4
    diray67 adlı üyeden alıntı: mesajı görüntüle
    PHP explode ile yapabilirsin
    Örnek makale linki bırakıyorum

    https://www.webcebir.com/149-php-exp...lme-dersi.html
    ben 2 tag arası almayı biliyorum. burda bi tag var sadece oda ":::" olan, nasıl alacağım acaba?
  • 25-01-2021, 18:59:52
    #5
    $text = 'test::::deneme
    test1::::deneme1
    test2::::deneme2
    test3::::deneme3
    test4::::deneme4';
    $lines = explode(PHP_EOL, $text);
    $lines = array_map(fn($item) => explode('::::', $item), $lines);
    $items = array_map(fn($item) => $item[0], $lines);
    sonuc: ['test1', 'test2', 'test3']

    test icin:
    http://sandbox.onlinephpfunctions.co...6e9ca55c728191
  • 25-01-2021, 19:06:56
    #6
    Zeta adlı üyeden alıntı: mesajı görüntüle
    $arr = explode("::::", $data);
    echo $arr[0];

    Array( [0] => test [1] => [2] => deneme test1 [3] => [4] => deneme1 test2 [5] => [6] => deneme2 test3 [7] => [8] => deneme3 test4 [9] => [10] => deneme4)

    çıktıyı böyle veriyor hocam.
  • 25-01-2021, 19:08:17
    #7
    phpcs adlı üyeden alıntı: mesajı görüntüle
    $text = 'test::::deneme
    test1::::deneme1
    test2::::deneme2
    test3::::deneme3
    test4::::deneme4';
    $lines = explode(PHP_EOL, $text);
    $lines = array_map(fn($item) => explode('::::', $item), $lines);
    $items = array_map(fn($item) => $item[0], $lines);
    sonuc: ['test1', 'test2', 'test3']

    test icin:
    http://sandbox.onlinephpfunctions.co...6e9ca55c728191
    Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' in C:wamp64wwwssindex.php on line 12

    $lines = array_map(fn($item) => explode('::::', $item), $lines);


    hata verdiği yer burası hocam.
  • 25-01-2021, 19:17:04
    #8
    dilenci adlı üyeden alıntı: mesajı görüntüle
    Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' in C:wamp64wwwssindex.php on line 12

    $lines = array_map(fn($item) => explode('::::', $item), $lines);


    hata verdiği yer burası hocam.
    $text = 'test::::deneme
    test1::::deneme1
    test2::::deneme2
    test3::::deneme3
    test4::::deneme4';
    
    $lines = explode(PHP_EOL, $text);
    $lines = array_map(function ($item) { return explode('::::', $item); }, $lines);
    $items = array_map(function ($item) { return $item[0]; }, $lines);
    
    print_r($items);
    eski ve artik desteklenmeyen bir PHP surumu kullandiginiz icin o hatayi aliyorsunuz. yukaridaki kod calisir.
  • 25-01-2021, 19:18:49
    #9
    phpcs adlı üyeden alıntı: mesajı görüntüle
    $text = 'test::::deneme
    test1::::deneme1
    test2::::deneme2
    test3::::deneme3
    test4::::deneme4';
    
    $lines = explode(PHP_EOL, $text);
    $lines = array_map(function ($item) { return explode('::::', $item); }, $lines);
    $items = array_map(function ($item) { return $item[0]; }, $lines);
    
    print_r($items);
    eski ve artik desteklenmeyen bir PHP surumu kullandiginiz icin o hatayi aliyorsunuz. yukaridaki kod calisir.
    çok teşekkür ederim sorunsuz çalıştı.

    php sürümümde 7.2.5 eskide sayılmaz