我们如何在laravel或php中检查数组中的值?

时间:2016-11-16 06:55:33

标签: php laravel

我有一张表格,供客户详细说明。在我的表中,我有一个实地电话。 目前的电话看起来像

customer_details - >呼叫

voicemail, voicemail_msg1, voicemail_msg2, voicemail_msg3

我需要列出来电数据。但我不需要Voice Message, Voice Message 1, Voice Message 2, Voice Message 3我需要列出Voice Message, Voice Message 1, Voice Message 2, Voice Message 3

因此,需要显示这些数据voicemail, voicemail_msg1, voicemail_msg2, voicemail_msg3而不是<td>{{ $labels->checkVoiceMailLabel($call->id, $call->answered_by) }}</td> 。是否可以使用数组检查或任何其他内置函数?

我附上了图片Here is the view

所以这个目的我已经添加了一些代码,请检查并纠正我

HTML

public function checkVoiceMailLabel($id, $answered_by)
    {
        //dd($answered_by);
        $result = '';
        $voicemail = [
            "voicemail"       => trans("messages.callListTableVoicemail"),
            "voicemail_msg1"  => trans("messages.callListTableVoicemail1"),
            "voicemail_msg2"  => trans("messages.callListTableVoicemail2"),
            "voicemail_msg3"  => trans("messages.callListTableVoicemail3"),
            "voicemail_msg4"  => trans("messages.callListTableVoicemail4"),
            "voicemail_msg5"  => trans("messages.callListTableVoicemail5"),
            "voicemail_msg6"  => trans("messages.callListTableVoicemail6"),
            "voicemail_msg7"  => trans("messages.callListTableVoicemail7"),
            "voicemail_msg8"  => trans("messages.callListTableVoicemail8"),
            "voicemail_msg9"  => trans("messages.callListTableVoicemail9"),
            "voicemail_msg10" => trans("messages.callListTableVoicemail10")
        ];

        dd($voicemail[$answered_by]);

        if($answered_by == $voicemail[$answered_by]){
            $result = $voicemail[$answered_by];
        }
        else{
            $result            = Call::select('answered_by')
                ->where('id', $id)
                ->where('answered_by', $answered_by)
                ->first();
        }
        /*dd($result);*/
    }

Controller.php这样

Voice Message
Voice Message 1 
message1
Voice Message 2
Voice Message 3
message2 
message3

所以期待的结果是:

{{1}}

0 个答案:

没有答案