I’d like to replace the ‘baz’ values in the ‘BLOCKS’ array with the arrays within the ‘BAZ’ array whose titles match.
I’ve tried exploding BLOCKS[‘baz’], then looping through the result and doing a str_replace to no avail. I’m sure there’s a more succinct and direct solution.
See DESIRED OUTPUT at the bottom for what I’m trying to accomplish. Many thanks!
BLOCKS
array
0 =>
array
'foo' => string 'block1' (length=6)
'bar' => string '/uploads/commercial/pdf.pdf' (length=27)
'baz' => string '372|371' (length=7)
1 =>
array
'foo' => string 'block2' (length=6)
'bar' => string '/uploads/commercial/pdf.pdf' (length=27)
'baz' => string '371' (length=3)
BAZ
array
372 =>
array
'wibble' => string 'building2' (length=9)
'wobble' => int 235000
'wubble' => string 'office|medical' (length=14)
371 =>
array
'wibble' => string 'building1' (length=9)
'wobble' => int 252000
'wubble' => string 'office' (length=6)
DESIRED OUTPUT
array
0 =>
array
'foo' => 'block1'
'bar' => '/uploads/commercial/pdf.pdf'
'baz' => array(
372 =>
array
'wibble' => string 'building2' (length=9)
'wobble' => int 235000
'wubble' => string 'office|medical' (length=14)
371 =>
array
'wibble' => string 'building1' (length=9)
'wobble' => int 252000
'wubble' => string 'office' (length=6)
);
1 =>
array
'foo' => string 'block2' (length=6)
'bar' => string '/uploads/commercial/pdf.pdf' (length=27)
'baz' => array(
371 =>
array
'wibble' => string 'building1' (length=9)
'wobble' => int 252000
'wubble' => string 'office' (length=6)
)
);
Try this: