This is what I wrote :
$Myprovince = (
($province == 6) ? \"city-1\" :
($province == 7) ? \"city-2\" :
($province == 8) ? \"city-3\" :
($province == 30) ? \
I understand this is a question about PHP, but since this is just an educational exercise anyways I thought you might be interested in learning that Ruby and Javascript actually behave the way you expect.
Ruby:
ree-1.8.7-2012.02 :009 > def foo x
ree-1.8.7-2012.02 :010?> x == 1 ? "city 1" : x == 2 ? "city 2" : "out of borders"
ree-1.8.7-2012.02 :011?> end
=> nil
ree-1.8.7-2012.02 :012 > foo 1
=> "city 1"
ree-1.8.7-2012.02 :013 > foo 2
=> "city 2"
ree-1.8.7-2012.02 :014 > foo 3
=> "out of borders"
Javascript:
> function f(x) { return x == 1 ? "city 1" : x == 2 ? "city 2" : "out of borders"; }
undefined
> f(1)
"city 1"
> f(2)
"city 2"
> f(3)
"out of borders"