Concatenate a string inside an array
-
Not necessarily WordPress specific but thought I’d post in here anyway…
I’m writing a simple plugin that adds a couple of custom post types. I’ve done this many times before, but now trying to make my code a bit more reusable so attempting to make some changes.
My custom post type is defined in a class.
I then define the post type name as a constant so I can reuse it throughout the code. I want to prefix the post type to the beginning of all of my field IDs. Thought I could just do the below but I’m getting an error: Parse error: syntax error, unexpected ‘.’, expecting ‘)’ on the line where I’m trying to concatenate the constant and the field ID.
class PostTypeTeam { const POST_TYPE = "xyz_team"; private $_meta = array( array( 'name' => 'Job title', 'id' => SELF::xyz_team . '_jobtitle', 'type' => 'text', 'std' => '', 'desc' => '' ) );
….code continues
The $_meta is passed to a function that loops through all the fields and controls the display output.
- The topic ‘Concatenate a string inside an array’ is closed to new replies.