Jump to content

useful php function


Recommended Posts

function delete_values_from_array($arr,$to){
	$res=array();
	for($k=0;$k<count($arr);$k++){
		if ($k>$to){
			array_push($res,$arr[$k]);
		}
	}
return $res;
}
function mysqli_execute_all(){
	$args = func_get_args();
	if (func_num_args()<2){ return false;}
	$stmt = $args[0]->prepare($args[1]);
	$finalarr=delete_values_from_array($args,2);
	$stmt->bind_param($args[2],extract($finalarr));
	$stmt->execute();
	$result = $stmt->get_result();
	return $result;
}

treat mysql injection +_+

بالتوفيق

Edited by Master_MTA
  • Like 2
Link to comment
  • 1 month later...
$n = 0;
function calc(int $x ,$o, int $y){
	switch ($o) {
    case "+":
       		$n = $x + $y ;
        break;
    case "-":
       		$n = $x - $y ;
        break;
    case "*":
        	$n = $x * $y ;
        break;
    case "/":
        	$n = $x / $y ;
        break;
    default:
        	$n = "SENTEX ERROR!" ;
	}
  return $n ;
}
  echo " = ". calc(1,"+",3) ;

SIMPLE CALC FUNCTION ;)

  • Confused 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...