Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Biology Forums - lokakuu 17, 2013, 04:40:04 IP

Otsikko: Adding an argument in the middle of an array
Kirjoitti: Biology Forums - lokakuu 17, 2013, 04:40:04 IP
So here's the array:

array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" border="0" />',


I've like to add an argument like:

<img src="$1" IF(SOMETHING) DO SOMETHING ELSE DO SOMETHING alt="" border="0" />',

How do I add a PHP argument like that?
Otsikko: Re: Adding an argument in the middle of an array
Kirjoitti: Arantor - lokakuu 17, 2013, 04:41:22 IP
You can't just blindly do that. We need *specifics* to help you with this because otherwise it's going to mess up (guaranteed, owing to inline ternary vs concatenation operator precedence)
Otsikko: Re: Adding an argument in the middle of an array
Kirjoitti: Biology Forums - lokakuu 17, 2013, 04:43:28 IP
Lainaus käyttäjältä: Arantor - lokakuu 17, 2013, 04:41:22 IP
You can't just blindly do that. We need *specifics* to help you with this because otherwise it's going to mess up (guaranteed, owing to inline ternary vs concatenation operator precedence)

I've made backups in case it breaks. Any suggestions? I really want to learn this.

It's nothing specific, I just took that code randomly from subs.php...
Otsikko: Re: Adding an argument in the middle of an array
Kirjoitti: Arantor - lokakuu 17, 2013, 04:51:34 IP
My suggestion is that I NEED you to be specific because you're going to be doing things like:

'content' => '<img src="$1"' . (some expression ? first value : second value) . ' alt="" border="0" />',
Otsikko: Re: Adding an argument in the middle of an array
Kirjoitti: Biology Forums - lokakuu 17, 2013, 05:03:01 IP
Great, I learned something new today. TY