Dizideki Oturumları Kontrol?

0 Cevap php

|: hmm i ev ödevi, onun 2 saat var ve ben hala hiçbir ipucu var

böyle

$sessions['lefthand'] = 'apple';
$sessions['righthand'] = '';
$sessions['head'] = 'hat';
$sessions['cloth'] = '';
$sessions['pants'] = '';

// here is the homework function
CheckSession('lefthand,righthand,head,cloth,pants');

we have some string "lefthand,righthand,head,cloth,pants" question is : " how can we check if the five session is not null or exist and display which session is empty ( if there is an empty session ) if all exist then returns a true ?

empty righthand , pants, and cloth.

Bu i düşünmek nasıl

  1. Bu diziler patlayabilir
  2. ! boş kimliği bir orada ise bir güle bir kontrol

Burada * Edit4 :) yapılan ive ilerleme

function CheckSession($sessions){
$all_sessions_exist = true;
$keys = explode(',',$sessions);
$error = array();
    // Search for Session that are not exist
    foreach ($keys as $key) {
        if (!isset($_SESSION[$key]) && empty($_SESSION[$key])) {
            echo "no $key</br>";
            $all_sessions_exist = false; 
        }
    }
return $all_sessions_exist;
}

Bir göz için teşekkürler

Adam Ramazan

0 Cevap