Jump to content

moxol

New Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by moxol

  1. Yes, I am using regex preg_match_all to find offset of matches so that I could use substr to the position of PREG_OFFSET_CAPTURE. And then I would use mb_strlen(substr($text, 0, $offset_capture)) to find "real" offset if there are multibytes in the text.
  2. I think I found the soluton: $offset = mb_strlen(substr($text, 0, $offset_capture)) Is this ok?
  3. If I use that offset in substr() then it would give me wrong substring. How to solve this issue?
  4. Function preg_match_all($pattern, $subject, PREG_OFFSET_CAPTURE ) returns wrong offset for matched value if there are multibyte characters in subject. It seems that PHP counts multibyte character as two characters instead of one. Is there a solution to this problem?
  5. I have problems matching text if I use the /u switch. First, I want to show code that works fine: $input = "• nemir s pojačanim pokretima tijela"; preg_match("/nemir/iu", $input, $match) ; $output = $match[0]; echo 'output:' . $output; But, if I change $input to substr($input, 1) then preg_match doesn't match anything: $input = "• nemir s pojačanim pokretima tijela"; $input = substr($input, 1); preg_match("/nemir/iu", $input, $match) ; $output = $match[0]; echo 'output:' . $output . "<br/>"; I tried without the /u switch, and it works, but I need the /u switch. I don't know what the issue is, but my guess is that has something to do with the symbol • at the beggining. Can someone help me?
  6. I am little bit embarrassed to say, but there was a next line: if($row['aktivan']=1) Obviously, = should be == Sorry, I will take 🔨 and accelerate it towards my
  7. I have a table korisnici in SQLite with INTEGER field aktivan that can have only 0 or 1 value (CHECK constraint). Field aktivan has value 0 but PHP returns value 1, why? Is this a bug? This is PHP code that I am running: $sql = "SELECT ime, aktivan FROM korisnici WHERE lower(ime) = '" . $ime . "'" . " AND sifra = '" . $_POST["sifra"] . "'"; $result = $db->query($sql); $row = $result->fetchArray(SQLITE3_ASSOC); $row['aktivan'] = 1 but in table the value is 0. When I run same query in DB Browser for SQLite I get correct value 0. Is this a bug?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.