Find - in a word
Moderator: General Moderators
Find - in a word
Hello. I want to make a function that will store a string in a variable. If there is a dash (-) in the string, it will set the variable to NULL, if it has no dashes then it will store that string in the variable. How can i do that? Thanks!
Re: Find - in a word
you can use something like this:xionhack wrote:Hello. I want to make a function that will store a string in a variable. If there is a dash (-) in the string, it will set the variable to NULL, if it has no dashes then it will store that string in the variable. How can i do that? Thanks!
Code: Select all
$variable = strrpos($string, "-") ? $string : null;Re: Find - in a word
Almost.koen.h wrote:Code: Select all
$variable = strrpos($string, "-") ? $string : null;
Code: Select all
$variable = (strpos($string, "-") !== false) ? null : $string;