在PHP中,如何在对象值中设置一个数组
我正在使用PHP。我有一系列的值,我需要在
$objAcessoExternoParticipanteDTO = new AcessoExternoDTO();
$objAcessoExternoParticipanteDTO->setNumIdAtividade($myArray);
array(49) {
[0]=>
string(5) "25208"
[1]=>
string(5) "25230"
[2]=>
string(5) "25239"
[3]=>
string(5) "25242"
[4]=>
string(5) "25243"
[5]=>
string(5) "25244"
[6]=>
string(5) "25247"
[7]=>
string(5) "25250"
[8]=>
string(5) "25251"
[9]=>
string(5) "25252"
}
我想通过的对象$ myarray中设置此值,这可能吗?
I'm using PHP. I have an array of values and i need set this value in a object
$objAcessoExternoParticipanteDTO = new AcessoExternoDTO();
$objAcessoExternoParticipanteDTO->setNumIdAtividade($myArray);
array(49) {
[0]=>
string(5) "25208"
[1]=>
string(5) "25230"
[2]=>
string(5) "25239"
[3]=>
string(5) "25242"
[4]=>
string(5) "25243"
[5]=>
string(5) "25244"
[6]=>
string(5) "25247"
[7]=>
string(5) "25250"
[8]=>
string(5) "25251"
[9]=>
string(5) "25252"
}
$myArray is what i'm trying to pass, is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果要包含来自数组中每个值的对象的实例,则必须创建
count($ myArray)
唯一命名的对象(它们可能很快会很快变得凌乱),或者存储所有另一个数组中的对象,像这样的结果
If you want an instance of this object containing each of the values from the array you will either have to create
count($myArray)
uniquely named objects (which could get very messy very quickly) or store all the objects in another array, like thisRESULT