I wanted to create this to ask some questions about the new Format functions released in 3.2.8.
The first one I want to ask about is how to use L&L to access array data. Now that we have Format regex that is outputting an array. Based on the docs, it looks like we can do this with <Format list index=0>, <Format list index=1> etc which is great.
This works, but I’m also getting a PHP notice of "Only variables should be passed by reference in /wp-content/plugins/tangible-loops-and-logic/vendor/tangible/template-system/template/format/list.php on line 22"
Another thing I wanted to see is if capture groups work. I did some testing, and from what I can tell, they do not… Is this something that can be added that could go in the with="$1"
An example could be something like <Format replace="/(\d{3})(\d{3})(\d{4})/" with="$1-$2-$3">1234567890</Format> would output 123-456-7890
I believe there is no need to pass the result by reference? If so, the warning can be fixed by assigning the result to a variable and passing that variable instead:
Hi Zack, thanks for starting this discussion thread about the new format functions.
About the PHP notice: indeed, that’s due to the peculiarity of PHP array functions, that some of them are not able to be chained together. Exactly, as you suggested, there needs to be a temporary variable to pass to array_shift. I’ll apply your fix and release in the next version soon. I’m surprised it still works with the notice.
About capture groups: great idea, I’ll look into adding support for this.