How to compare string with accents in php

0

I have a problem that I could not resolve in php, I have a field varchar in MySQL with accentuation, I make a rescue of it and use htmlentities so that the string gets the correct accent. I need to compare the variable coming from the bank and mark a radio field if the condition is true, but I can not, what I have and this:

Variable Redemption:

$Motivo = htmlentities($row_DocContratacao['MotivoContratacao']);

Value Comparison

<input type="radio" name="Motivo" id="motivo-4" value="Recontratação"<?php if ($Motivo=="Recontratação") echo ' checked="checked"'; ?> /> 

The value redeemed is Recontratação but the radio field is not marked.

    
asked by anonymous 15.06.2015 / 14:56

1 answer

1

When using the htmlentities you will be changing the String to "Recontract & amp; amp; amp; amp; amp; amp;

Try to convert within your IF to get the expected result, here's an example of how to do it.

<input type="radio" name="Motivo" id="motivo-4" value="Recontratação"<?php if ($Motivo==htmlentities("Recontratação")) echo ' checked="checked"'; ?> /> 
    
15.06.2015 / 16:00