I'm trying to reference the key/value pair of an item in the same array:
$glossary_args = array(
'name' => 'Glossary Terms',
'singular_name' => 'Glossary Term',
'add_new' => 'Add New Term',
'edit_item' => 'Edit Term',
'search_items' => 'Search'.$glossary_args["name"],
)
Is this even possible? If so, how?
You can use the fact that assignment is itself an expression in PHP:
$glossary_args = array(
'name' => ($name = 'Glossary Terms'),
'singular_name' => 'Glossary Term',
'add_new' => 'Add New Term',
'edit_item' => 'Edit Term',
'search_items' => 'Search'.$name
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With