tengo una duda, y es que me gustaria que en el final no me pusiera la coma (,)
cómo puedo hacerlo?
esta es mi variable
Código:
mi función:$ds = array( "id"=>array( "name"=>"id", "type"=>"int", "mapping"=>"id"), "cif"=>array( "name"=>"cif", "type"=>"string", "mapping"=>"cif"), "alias"=>array( "name"=>"alias", "type"=>"string", "mapping"=>"alias"), "name"=>array( "name"=>"name", "type"=>"string", "mapping"=>"name"), "address"=>array( "name"=>"address", "type"=>"string", "mapping"=>"address"), "phone"=>array( "name"=>"phone", "type"=>"string", "mapping"=>"phone"), "fax"=>array( "name"=>"fax", "type"=>"string", "mapping"=>"fax"), "email"=>array( "name"=>"email", "type"=>"string", "mapping"=>"email"), "contact"=>array( "name"=>"contact", "type"=>"string", "mapping"=>"contact"), "contact_phone"=>array( "name"=>"contact_phone", "type"=>"string", "mapping"=>"contact_phone"), "contact_email"=>array( "name"=>"contact_email", "type"=>"string", "mapping"=>"contact_email"), "comments"=>array( "name"=>"comments", "type"=>"string", "mapping"=>"comments"), "logo"=>array( "name"=>"logo", "type"=>"string", "mapping"=>"logo") );
Código:
el codigo de arriba me devuelve este codigoforeach ($ds as $key => $value ){ $dataStore.="{"; foreach ($value as $key2 => $value2){ $dataStore.=$key2.": '".$value2."', "; } $dataStore.="},"; } echo "<br><br><br>"; echo $dataStore;
Código:
{name: 'id', type: 'int', mapping: 'id', }, {name: 'cif', type: 'string', mapping: 'cif', }, {name: 'alias', type: 'string', mapping: 'alias', }, {name: 'name', type: 'string', mapping: 'name', }, {name: 'address', type: 'string', mapping: 'address', }, {name: 'phone', type: 'string', mapping: 'phone', }, {name: 'fax', type: 'string', mapping: 'fax', }, {name: 'email', type: 'string', mapping: 'email', }, {name: 'contact', type: 'string', mapping: 'contact', }, {name: 'contact_phone', type: 'string', mapping: 'contact_phone', }, {name: 'contact_email', type: 'string', mapping: 'contact_email', }, {name: 'comments', type: 'string', mapping: 'comments', }, {name: 'logo', type: 'string', mapping: 'logo', },
Como podeis ver, entre ellos tengo que separarlos por (,) pero el último no,
Me podeis hechar una mano?
Gracias