In the database there is a table with fields and textual information. In the table there is a field message1 which contains the text 'lateness more than 15min' and 'lateness less than 15min'. I can’t understand how to build a condition in which,, it will be so if in column message1 there is a phrase “lateness is more than 15min” then write 0. If there is a “delay less than 15min” then write 1. $ row contains an array of data from the database

foreach($row as $k=>$val) { foreach ($val as $value=>$last) { echo '<pre>'; print_r ($row); echo '</pre>'; } } 
  • usually do the opposite: a flag of 0 or 1 is pulled out in the database, and at the presentation level it is determined how to show it. In any case, give an example of what you have in the row and what you want to get at the output. - teran

1 answer 1

You can use the strpos function and find the occurrence of the substring 'more' in the input. Something like:

 $findme = 'более'; $pos = strpos($row, $findme); if ($pos === false) { print_r('0'); } else { print_r('1'); } 

And nevertheless, @teran in the comments is right - it only makes sense to store flags in the database, and to expand the expanded phrases only during data output