name : class.Util.php
<?php
class Util {

    public function getValueFromKeyArray($array,$key) {
        if($array[$key]=="") {
            return $key;
        }else {
            return $array[$key];
        }
    }

    public function splitDataToOption($data,$matchValue,$delimeter) {
        $arrData = split($delimeter, $data);
        for($i=0;$i<count($arrData);$i++) {
            if($arrData[$i] == $matchValue) {
                echo "<option value=\"".$arrData[$i]."\" selected=\"selected\">".$arrData[$i]."</option>";
            }
            else {
                echo "<option value=\"".$arrData[$i]."\">".$arrData[$i]."</option>";
            }
        }
    }
    public function arrayToOption($arrValue,$arrData,$matchValue) {
        if($arrData == null) {
            $arrData == $arrValue;
        }
        for($i=0;$i<count($arrValue);$i++) {
            if($arrValue[$i] == $matchValue) {
                echo "<option value=\"".$arrValue[$i]."\" selected=\"selected\">".$arrData[$i]."</option>";
            }
            else {
                echo "<option value=\"".$arrValue[$i]."\">".$arrData[$i]."</option>";
            }
        }
    }
    public function arrayKeyToOption($arrValue,$matchValue) {
        foreach($arrValue as $key => $value) {
            //            echo $key;
            if($key == $matchValue) {
                echo "<option value=\"".$key."\" selected=\"selected\">".$value."</option>";
            }
            else {
                echo "<option value=\"".$key."\">".$value."</option>";
            }
        }
    }

    public function printResult($success,$error) {
        if(count($success)!=0) {
            echo "<div class=\"greenbox\">";
            for($i=0;$i<count($success);$i++) {
                echo "<p>".$success[$i]."</p>";
            }
            echo "</div>";
        }
        if(count($error)!=0) {
            echo "<div class=\"redbox\">";
            for($i=0;$i<count($error);$i++) {
                echo "<p>".$error[$i]."</p>";
            }
            echo "</div>";
        }
    }
    public function textFormatter($text,$arrReplace) {
        return strtr($text, $arrReplace);
    }
}
?>

© 2024 UnknownSec