Friday, August 31, 2012

if statement

Hi ppl...
I'm an absolute beginner in programming and what I ask, maybe is very simple, but i need it very much and soon :)

So the problem is in if statement

I write
$this->set('position', 0);

if(in_array($_GET['var'], $this->Word->findById(11)))
{
$this->set('position', $this->array_search($_GET['var'],$this->Word->findById(11)));

} 

or 

$position = 0;
$var_get = $_GET['var'];
$word = $this->Word->findById(11);

if(in_array($var_get, $word ))
{
$position = $this->array_search($var_get,$word);
}
$this->set('position', $position );


but when I write

echo $position
in view.ctp, it always echoes 0.
It means that $position = $this->array_search($var_get,$word); doesn't work???
Or what is wrong.
Tell me please.
Thanks

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: