Sample array:
array( 'keyword-one' => 'value', 'keyword-two' => 'value' );
What can I do so I get returned an array with keyword- omitted from the key so:
array( 'one' => 'value', 'two' => 'value' );
Sample array:
array( 'keyword-one' => 'value', 'keyword-two' => 'value' );
What can I do so I get returned an array with keyword- omitted from the key so:
array( 'one' => 'value', 'two' => 'value' );
Use str_replace()
to replace in the keys from array_keys()
and combine with the values using array_combine()
:
$array = array_combine(str_replace('keyword-', '', array_keys($array)), $array);
For more complex patterns use preg_replace().