December 23, 201114 yr Hello, Ive looked everywhere for a function that can take a string and turn it into a boolean for example team NOT worker change to team -worker but not had much look finding one im planning on using IN BOOLEAN MODE on mysql to get the people who meet the boolean search Any help would be great, Many Thanks, Gary
December 24, 201114 yr not sure, if i get what you want. boolen has only true or false. string with value turned into boolean is allways true! <?php $string = 'I am a string'; var_dump($string); echo '<hr>'; $bool = (bool)$string; var_dump($bool);
December 24, 201114 yr Author not sure, if i get what you want. boolen has only true or false. string with value turned into boolean is allways true! <?php $string = 'I am a string'; var_dump($string); echo '<hr>'; $bool = (bool)$string; var_dump($bool); yes that gives true or false, im looking for the search boolean, for example a user searches cars NOT motorbikes, it would change it to cars -motorbikes for the sql in boolean mode
December 28, 201114 yr its okay ill just make my own function Heres a starting point. <?php function format_query_criteria($string) { $string = preg_replace('/(not\s)/i', '-', $string); return $string; } echo format_query_criteria("Cars NOT motorbikes"); // echos: Cars -motorbikes
December 28, 201114 yr its okay ill just make my own function why not just forget the Boolian stuff and do plain old full text searching lol
December 28, 201114 yr yes that gives true or false, im looking for the search boolean, for example a user searches cars NOT motorbikes, it would change it to cars -motorbikes for the sql in boolean mode Both you fail lol because you didn;t read the question No I didn't. He wanted a way to convert "Cars not motorbikes" into "Cars -motorbikes", thats what that function I wrote does. If someone types in 'Cars not motorbikes', it will convert 'not ' into '-' for the query. By the way when using full text searching, using the + sign isn't needed, typing '+chips -bread' is the same as 'chips -bread'. Edited December 28, 201114 yr by PHP Monkey
December 29, 201114 yr Author why not just forget the Boolian stuff and do plain old full text searching lol client insists i use boolean lol
December 29, 201114 yr Author Sure I've just read somewhere that you said you have 6 years php experience. If so, you've done very well to not have come across full text searching. well ive been learning/coding for 6 years yes, i have came across it and i have messed about with +this -that but i have never had to use it in a website i have made but this particular client now insists i have a boolean search EDIT just so you know i encouraged the client in the end that boolean search isnt really essential so ive not done it now as couldnt be bothered making the function when there was no gain from it for either me or the client but if anyone has got a function that does it then please let me know as its better for him to have than not Edited December 29, 201114 yr by web-itec
Create an account or sign in to comment