Question

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

Was it helpful?

Solution

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

seems to do exactly what you're asking

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top