strstr function |
[eluser]Dynamica Technology[/eluser]
Hi I have this code Code: $needle = ','; when run the app I have this error Quote:Severity: Warning if not use the needle the function work. Could you help me. Thanks
[eluser]GDmac - expocom[/eluser]
PHP 5.3.0 Added the optional parameter before_needle. http://php.net/strstr bonus: your $before_needle = "True"; is actually a string. "False" != False. http://php.net/boolean
[eluser]Dynamica Technology[/eluser]
I know is a string, but also if write TRUE or true have the same error I read more post that have same problem in a linux server, but in windows server work
[eluser]Aken[/eluser]
What version of PHP are you using? The third parameter was not added until 5.3.0.
[eluser]Dynamica Technology[/eluser]
Thanks I view now that my hosting not use 5.3.0 ( my hosting use 5.2.17, in local I have 5.3.14) now how bypass this problem I need to retrieved a string before "," and a string after ","
[eluser]PhilTem[/eluser]
Assuming you have a comma only once in your string to search Code: $pos_comma = strpos($string_to_search, ','); will return everything before the comma (w/o the comma) and after the comma (again w/o the comma) Edit: Actually this works for more than one comma in your string, but it will split the string according to the position of your first comma. Just to clarify ![]()
[eluser]CroNiX[/eluser]
Or you could just Code: list($left_text, $right_text) = explode(',', $string);
[eluser]Narf[/eluser]
[quote author="CroNiX" date="1352830542"]Or you could just Code: list($left_text, $right_text) = explode(',', $string); No assumptions: Code: list($left_text, $right_text) = explode(',', $string, 2); Another note - the original example shows this: Code: $before_needle = 'TRUE'; Which is wrong, it should be boolean.
[eluser]Dynamica Technology[/eluser]
[quote author="Narf" date="1352834789"][quote author="CroNiX" date="1352830542"]Or you could just Code: list($left_text, $right_text) = explode(',', $string); No assumptions: Code: list($left_text, $right_text) = explode(',', $string, 2); Another note - the original example shows this: Code: $before_needle = 'TRUE'; Which is wrong, it should be boolean.[/quote] I know, I said in prior post |
Welcome Guest, Not a member yet? Register Sign In |