質問

What I'm trying to achieve is something like this:

Hash::set($result, 'Model.{n}.field', 'replacementvalue');

But there doesn't seem to be a function in the hash class that does this. How can I achieve this without a foreach loop?

Edit: made it more clear I'm replacing a value not setting a new one

役に立ちましたか?

解決

$result = Hash::insert($result, 'Model.{n}.field', 'newvalue')

seems to do exactly what you're asking

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top