I am getting error
"Undefined index at Line Number: 233" which is
if($rule[$item] == '@' && isset($keys[$index + 1]))
and another at line 244 which is
$keys);
Function which is called is:
public function preeti()
{
$rule =
[
"c" => "d",
"a" => "o",
"t" => "g",
"h" => "a",
"1" => "@",
"e" => "n",
"n" => "t"
];
$input = $this->input->get('preeti');
$keys = str_split($input);
$output = [];
array_walk($keys,
function($item, $index) use($rule,$keys, &$output) {
if($rule[$item] == '@' && isset($keys[$index + 1])) {
$output[] = $rule[$keys[$index + 1]];
return;
}
if(isset($keys[$index - 1]) && $rule[$keys[$index - 1]] == '@') {
$output[] = '@';
return;
}
$output[] = $rule[$item] ?? null;
return;
},
$keys);
$final_output = implode($output);
$this ->load->blade('index.preeti-to-unicode',[
'preeti' => $input,
'unicode' => $final_output,
]);
}
When I try to load view page (using CodeIgniter framework) calling preeti()
function,it shows the following error. Screenshot :
I think the error is because of missing ?? null
somewhere because maybe it can't handle input value which can't be found in an array.