Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/08/2022 in all areas

  1. Alternative sans-regex solution... Input (test.txt) Large toolbox (metal) for sale (hammer is required) serious inquiries only. All employees are required to attend. Meeting scheduled for Tuesday (Formal attire required) otherwise call (or email) us. Code $data = file('test.txt', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); foreach ($data as $line) { if ($p = parens_and_req($line)) { $line = str_replace($p, "<span style='color:red;'>$p</span>", $line ); } echo "<p>$line</p>"; } function parens_and_req($str) { $k = strlen($str); $p2 = 0; while (( $p1 = strpos($str, '(', $p2)) !== false ) { $p2 = strpos($str, ')', $p1); if ($p2 === false) { $p2 = $k-1; } $parens = substr($str, $p1, $p2-$p1+1); if (strpos($parens, 'required') !== false) { return $parens; } } return false; } Output
    1 point
  2. Use DATE type columns for your dates, not varchar. Have your leaving dates either a valid date or NULL. SELECT eemp_id , fname , lname , AVG(timestampdiff(MONTH, joining_date, coalesce(leaving_date, curdate()))) as av_mths FROM employee_details ed JOIN employee e ON e.empid = ed.eemp_id GROUP BY eemp_id HAVING av_mths >= 36;
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • 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.