Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
╰┈➤ Create a function that determines whether a string is a valid hex code. The hex code must begin with a pound key # and is exactly 6 characters in length. Each character must be a digit from 0-9 or an alphabetic character from A-F. All alphabetic characters may be uppercase or lowercase. ◄
function isSpecialArray($str) {
    $length = strlen($str);
    $count=1;
    for ($i=1; $i<$length; $i++) {
	if ($str[0]="#") {
	    
► // 0123456789abcdefABCDEF
if ((ord($str[$i]) > 64 && ord($str[$i]) < 71) || (ord($str[$i]) > 47 && ord($str[$i]) < 58) || (ord($str[$i]) > 96 && ord($str[$i]) < 103)) { $count+=1; } } } if (strlen($str)==7 && $count==$length){ return true; } return false; } var_dump(isSpecialArray("#CD5C5B"));
`
by Luka Khitaridze
2 years ago
0
PHP
Problem solving
0
╰┈➤ The eval() function evaluates a string as PHP code. The string must be valid PHP code and must end with
semicolon.
// Example #1 eval() 
$string = 'cup';
$string2= 'coffee';
$str = 'This is a $string with $string2 in it.';
echo $str. "\n"; // outputs: This is a $string with $string2 in it.
eval("\$str = \"$str\";");
echo $str. "\n"; // outputs: This is a cup with coffee in it.
► Let's make another simple example for better understanding. Put a mathematical operation in a string. obviously PHP can't solve example in case of putting it in a string.◄
$operation =  "20 - 5"; 
echo $operation; // outputs 20 - 5
echo eval( $operation. ';' );  // it doesn't show anything.
echo eval( 'echo '. $operation. ';' ); // outputs 15
// or
eval( '$temp = ' .$operation. ';' );
echo $temp; // outputs 15
by Luka Khitaridze
2 years ago
0
PHP
Function
0
Write a function that takes an integer minutes and converts it to seconds.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Write a function that takes the base and height of a triangle and return its area.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
In this challenge, a farmer is asking you to tell him how many legs can be counted among all his animals. The farmer breeds three species: chickens = 2 legs cows = 4 legs pigs = 4 legs The farmer has counted his animals and he gives you a subtotal for each species. You have to implement a function that returns the total number of legs of all the animals.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Create a function that takes a string and returns it as an integer.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Given a Rubik's Cube with a side length of n, return the number of individual stickers that are needed to cover the whole cube. Pictures of Rubik's Cubes The Rubik's cube of side length 1 has 6 stickers. The Rubik's cube of side length 2 has 24 stickers. The Rubik's cube of side length 3 has 54 stickers.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Create a function that returns the smaller number.
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Create a function that takes the number of wins, draws and losses and calculates the number of points a football team has obtained so far. - wins get 3 points - draws get 1 point - losses get 0 points
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Given two strings, firstName and lastName, return a single string in the format "last, first".
by Tinatin Kvinikadze
2 years ago
0
PHP
Problem Solving
0
Results: 1578