Im trying to filter some entry's in a While loop. This i'm trying to do with the strpos
function, unfortunately when i use a variable as needle, i do not get an result.
No result:
$tra = strpos($HRreq, $entry_type)
result: $tra = strpos($HRreq, "string");
But, i need it to be variable in the while loop.
$select_exec = odbc_exec($amos_db,$select_personnel);
while ($row = odbc_fetch_array($select_exec)){
$username = $row['user_sign'];
$entry_type = $row['entry_type'];
$fullname1 = $row['lastname'] . $row['firstname'];
$fullname = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($fullname1))))));
$userno = $row['employee_no_i'];
$tra = strpos($HRreq, "$entry_type");
echo $entry_type ." = ". $tra;
}
I've added part of the code since the code is more than 500 lines long. I hope this is enough to get an idea of what i'm trying to accomplish
I discovered that the database returned with white spaces after the variable. I added a trim()
and the problem was solved. It was a silly mistake.