BirForum

BirForum (https://www.birforum.com/)
-   Bf Duyuru (https://www.birforum.com/bf-duyuru/)
-   -   Kodlar mantığı (https://www.birforum.com/bf-duyuru/8-kodlar-mantigi.html)

ImOriqinaL 01-06-2026 20:39

Kodlar mantığı
 
PHP Code:

<?php
  $METIN 
= <<<FOO
  Nuri: Erkek;Arapça;İsmin anlamı burada olacak
  Ahmet: Erkek;Farsça;İsmin anlamı burada olacak
  Deniz: Unisex;Farsça;İsmin anlamı burada olacak
  HASAN: Erkek;Farsça;İsmin anlamı burada olacak
  Ayhan; Deeme
  Anlamsız satır var burada.
  Meral: Kadın;Türkçe;Geyik, geyik yavrusu, dağ keçisi
  FOO;

  
// preg_match_all('/(?<isim>.*): (?<cinsiyet>(E|K|U).*);(?<kaynak>.*);(?<anlam>.*)/', $METIN, $SONUC);
  
preg_match_all('/(.*): ((E|K|U).*);(.*);(.*)/'$METIN$SONUC);
  unset(
$SONUC[0]);
  echo 
"<pre>";
  
print_r($SONUC);
  echo 
"</pre>";


  
$str="Bu akşam beni buralarda aramayın";

  
$ARANAN1 "ben";
  if (
preg_match("/$ARANAN1/"$str)) {
     echo 
"<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
     echo 
"<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  
$ARANAN2 "BEN";
  if (
preg_match("/$ARANAN2/"$str)) {
     echo 
"<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
     echo 
"<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  
$ARANAN3 "Ben";
  if (
preg_match("/$ARANAN3/i"$str)) {
     echo 
"<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
     echo 
"<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

HTML Code:

<?php
  $METIN = <<<FOO
  Nuri: Erkek;Arapça;İsmin anlamı burada olacak
  Ahmet: Erkek;Farsça;İsmin anlamı burada olacak
  Deniz: Unisex;Farsça;İsmin anlamı burada olacak
  HASAN: Erkek;Farsça;İsmin anlamı burada olacak
  Ayhan; Deeme
  Anlamsız satır var burada.
  Meral: Kadın;Türkçe;Geyik, geyik yavrusu, dağ keçisi
  FOO;

  // preg_match_all('/(?<isim>.*): (?<cinsiyet>(E|K|U).*);(?<kaynak>.*);(?<anlam>.*)/', $METIN, $SONUC);
  preg_match_all('/(.*): ((E|K|U).*);(.*);(.*)/', $METIN, $SONUC);
  unset($SONUC[0]);
  echo "<pre>";
  print_r($SONUC);
  echo "</pre>";


  $str="Bu akşam beni buralarda aramayın";

  $ARANAN1 = "ben";
  if (preg_match("/$ARANAN1/", $str)) {
    echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  $ARANAN2 = "BEN";
  if (preg_match("/$ARANAN2/", $str)) {
    echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  $ARANAN3 = "Ben";
  if (preg_match("/$ARANAN3/i", $str)) {
    echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

Kod:

<?php
  $METIN = <<<FOO
  Nuri: Erkek;Arapça;İsmin anlamı burada olacak
  Ahmet: Erkek;Farsça;İsmin anlamı burada olacak
  Deniz: Unisex;Farsça;İsmin anlamı burada olacak
  HASAN: Erkek;Farsça;İsmin anlamı burada olacak
  Ayhan; Deeme
  Anlamsız satır var burada.
  Meral: Kadın;Türkçe;Geyik, geyik yavrusu, dağ keçisi
  FOO;

  // preg_match_all('/(?<isim>.*): (?<cinsiyet>(E|K|U).*);(?<kaynak>.*);(?<anlam>.*)/', $METIN, $SONUC);
  preg_match_all('/(.*): ((E|K|U).*);(.*);(.*)/', $METIN, $SONUC);
  unset($SONUC[0]);
  echo "<pre>";
  print_r($SONUC);
  echo "</pre>";


  $str="Bu akşam beni buralarda aramayın";

  $ARANAN1 = "ben";
  if (preg_match("/$ARANAN1/", $str)) {
    echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  $ARANAN2 = "BEN";
  if (preg_match("/$ARANAN2/", $str)) {
    echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

  $ARANAN3 = "Ben";
  if (preg_match("/$ARANAN3/i", $str)) {
    echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
  } else {
    echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
  }

Alıntı:

<?php
$METIN = <<<FOO
Nuri: Erkek;Arapça;İsmin anlamı burada olacak
Ahmet: Erkek;Farsça;İsmin anlamı burada olacak
Deniz: Unisex;Farsça;İsmin anlamı burada olacak
HASAN: Erkek;Farsça;İsmin anlamı burada olacak
Ayhan; Deeme
Anlamsız satır var burada.
Meral: Kadın;Türkçe;Geyik, geyik yavrusu, dağ keçisi
FOO;

// preg_match_all('/(?<isim>.*): (?<cinsiyet>(E|K|U).*);(?<kaynak>.*);(?<anlam>.*)/', $METIN, $SONUC);
preg_match_all('/(.*): ((E|K|U).*);(.*);(.*)/', $METIN, $SONUC);
unset($SONUC[0]);
echo "<pre>";
print_r($SONUC);
echo "</pre>";


$str="Bu akşam beni buralarda aramayın";

$ARANAN1 = "ben";
if (preg_match("/$ARANAN1/", $str)) {
echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
} else {
echo "<p><b>$ARANAN1</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
}

$ARANAN2 = "BEN";
if (preg_match("/$ARANAN2/", $str)) {
echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
} else {
echo "<p><b>$ARANAN2</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
}

$ARANAN3 = "Ben";
if (preg_match("/$ARANAN3/i", $str)) {
echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:green; color: white;'><b>VAR</b></span></p>";
} else {
echo "<p><b>$ARANAN3</b> ifadesi <b>$str</b> cümlesinde <span style='background-color:red; color: white;'><b>YOK</b></span></p>";
}
Kod mesajları denemesini yapıyoruz..


Forum saati GMT +3 olarak ayarlanmıştır. Şu an saat: 23:38

Yazılım: vBulletin® - Sürüm: 3.8.11   Copyright ©2000 - 2026, vBulletin Solutions, Inc.
SEO by vBSEO 3.7