PDA

View Full Version : how to write the '-' in php items



hui2008
30 Jun 2008, 5:47 AM
In the js I can write like this:


header = Ext.extend(Ext.Toolbar,{
items:['-',{text:'tool1','-',{text:'tool2'}]
});
Ext.reg('headers',header);

now I can't the '-'


$head = array();
$head[] = array(
'-',///???????? how to do write this?
"text"=>"tool1"
);
$head[] = array(
"text"=>"menu2"
);

who can help me?

devnull
30 Jun 2008, 7:12 AM
besides this not being a php forum, i dont see why that wouldnt work...

troy.mccabe
30 Jun 2008, 1:06 PM
Look at the json_encode() of that:
[{"0":"-","text":"tool1"},{"text":"menu2"}]

You need:
["-",{"text":"tool1"},"-",{"text":"menu2"}]

Here's the code you need. Put the '-' as the first string in the array, before you make the other objects.

$head = array();
$head[] = "-";
$head[] = array("text"=>"tool1");
$head[] = "-";
$head[] = array("text"=>"menu2");

echo json_encode($head);

if I was understanding you correctly...the Javascript provided was missing a curly brace, so I'm assuming you wanted to two objects in the array...

Let me know if you need anything else.

Edit: You might need an extra set of quotes to make ext see the -'s as strings...fyi.

hui2008
30 Jun 2008, 5:01 PM
Thank you very much!=D>