我不确定你在哪里得到这个类,但这里有很多无效的命名
例子
$goal
campaign-ID
等等
我不得不重建你的班级,它看起来像这样
$st= new stdClass();
$st->{"campaign-ID"} = 1 ;
$st->campaign_name = "Sample Campaign" ;
$st->start_duration = "2012-04-17" ;
$st->start_duration = "2012-04-17" ;
$st->{'activity$'} = null ;
$st->survey_settings = "Ordering K-Cup Packs" ;
$st->{'$limit'} = "sample" ;
$st->{'$goal'} = null ;
$std = new stdClass();
foreach($st as $key => $value)
{
$key = str_replace(array('$',"-"),array('',"_"),$key);
$std->{$key} = $value ;
}
echo "<pre>" ;
print_r($std);
输出
stdClass Object
(
[campaign_ID] => 1
[campaign_name] => Sample Campaign
[start_duration] => 2012-04-17
[activity] =>
[survey_settings] => Ordering K-Cup Packs
[limit] => sample
[goal] =>
)
我建议您创建更有效的变量名称而不是此类转换