How can I replace empty elements in an array with “OTHER”?

My list (@degree) is built from a SQL command. The NVL command in the SQL isn't working, neither are tests such as:

if (@degree[$i] == "")
if (@degree[$i] == " ")
if (@degree[$i] == '')
if (@degree[$i] == -1)
if (@degree[$i] == 0)
if (@degree[$i] == ())
if (@degree[$i] == undef)

$i is a counter variable in a for loop. Basically it goes through and grabs unique degrees from a table and ends up creating ("AFA", "AS", "AAS", "", "BS"). The list is not always this long, and the empty element is not always in that position 3.

Can anyone help?

I want to either test during the for loop, or after the loop completes for where this empty element is and then replace it with the word, "OTHER".

Thanks for anything -Ken


First of all, the ith element in an array is $degree[$i], not @degree[$i]. Second, "==" is for numerical comparisons - use "eq" for lexical comparisons. Third of all, try if (defined($degree[$i]))

Need Your Help

android: pause (close) app so that it is re-opened on the same state

android android-activity destroy onkeydown

I have an app that records some data (time, user’s gps position etc). Now I want to implement this: when user presses back I pop an alertdialog with two options to “pause” or “exit”. I can do that

Creating instance for NSManagedObject Class using Restkit

iphone objective-c xcode core-data restkit

how can i create an instance for NSmanagedObject Class which i am created using core data model. I have another class which is the subclass of NSObject. I want to create an object for NSManageObject