What quotes to use

When declaring arrays is double quotes better than single quotes?

return array(“slug”=>$parentslug,“title”=>$parenttitle);

return array(‘slug’=>$parentslug,‘title’=>$parenttitle);

Most of the time it doesn’t matter, but double quoted strings support more complex syntax inside of them. So, the general rule of thumb is, use single quoted strings unless you have a reason to use the double quoted syntax. Whether or not you’re using them in relation to arrays is irrelevant.


only thing you cannot do is this
return array(‘slug’=>‘$parentslug’,‘title’=>$parenttitle);
but can do this
return array(‘slug’=>“$parentslug”,‘title’=>$parenttitle);
others all fine

Yes you can. $array[‘slug’] will contain ‘$parentslug’ :smiley:

yup,one thing you should not forget syntax errors are easier to detect but logical errors like that will keep for busy for nothing…:slight_smile:
so keep it for the day …when you feel bored…:smiley:
(long investigation …why is my array not working…)

no offence…