Jump to content

Finding var within string...


monkeytooth

Recommended Posts

I know this should be simple but its evading me at the moment, and giving me a headache.. No time to put aside and come back later unfortunately.. So any help would be greatly appreciated.

 

I am outputing a string xxxx-xxxx the x's can be anything or can be "none" I want to run the string through a filter of sorts to find out if it has "none" in it, where if it does then I have to make it re-output the string differently. What would be the simplest solution? would it be exploding it and then checking an array? or is there a simpler tactic?

 

The orginal output is $var1 = xxxx (pulled from DB), $var2 = xxxx (pulled from DB) $var3 = $var1 . "-" . $var2

 

I have it pull out that way cause I am swapping the database to a new format and in the previous version of the database some of the fields were left blank, null, or "none". In this case I am taking 2 fields and combining them into the $var3 string.. however. If var1 or 2 are blank or none, I want to have the string output the one thats not blank or none twice for sake of what the final outcome is to be later.. or if both are blank I want it to output just none.

Link to comment
https://forums.phpfreaks.com/topic/157637-finding-var-within-string/
Share on other sites

$paystart = $row_jobs['jpayrange'];
$payend = $row_jobs['jpayrangee'];

if($paystart == "") { $paystart = "none"; } else {}
if($payend == "") { $payend = "none"; } else {}

$payrange = $paystart . "-" . $payend;

 

if $payrange ends up having "none" in it somewhere, I want to replace which ever spot none was with either start or end

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.