I'm trying to build an array with a few variations of some data, when using preg_replace and echoing out values, it works like normal, but if I try to store those values in an array, the function simply returns nothing, and gives no error.
Here's a piece of the code I'm using, it's inside a class.
$actions = array();
foreach($controllers as $ck => $cv) {
$cvar = 'br'.$ck.'actions';
foreach(self::$$cvar as $key => $value) {
if ($key != $value) {
$actions[$value] = $key;
if( preg_match('/[A-Z]/',$key)!==0 || preg_match('/[A-Z]/',$value)!==0 )
{
$key2=strtolower(preg_replace('/(?<=\\w)([A-Z])/','-\\1',$key));
$value2=strtolower(preg_replace('/(?<=\\w)([A-Z])/','-\\1',$value));
$actions[$value2] = $key2; // Everything works except for this line, if I comment it, it works, if I don't, it simply doesn't return even an error.
}
}
}
}
return $actions;
What is causing this weird behaviour? It should be able to add to the array like normal, but it doesn't...
$key2
and$value2
to see what the values are? Perhaps usingerror_reporting(E_ALL);
could help while debugging