How to format a simple PHP array of strings?

ATIF

New Member
I have this simple function which I pass in an array of strings:\[code\]function myfunction( $arg = array() ){ // do stuff to $arg... // return a $string;}\[/code\]Simple so far, but I need some of the strings in the \[code\]$arg\[/code\] array to be formatted, while some remain unformatted. I can't figure out how to do it?Say I run this \[code\]$arg\[/code\] through \[code\]myfunction()\[/code\]:\[code\]echo myfunction( array( 'format me!', 'do not format me!' ) );\[/code\]My tiny little brain can't figure out how to tell \[code\]myfunction()\[/code\] that the first value in \[code\]$arg\[/code\] array needs to have formatting, and it should not format the second value.I thought about an associative array, but I think that could be the wrong approach because of having identical indexes.\[code\]echo myfunction( array( 'format' => 'hi', 'format' => 'bye', 'noformat' => 'foo');\[/code\]Just looking for a "nudge" in the right direction.EDIT 1:Forgot to mention, I can only have one \[code\]$arg\[/code\] array because I need the keys to be in a specific order.EDIT 2:The \[code\]$arg\[/code\] array can have as many keys as the user wants.
 
Back
Top