Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

rewrew

php

<?php
    $array = [2,3,4,5,3,7,2,2];
    $counted = [];
    
    foreach ($array as $k => $v) {
        if (!isset($counted[$v])) {
            $counted[$v] = 0;
        }
        
        $counted[$v]++;
    }
    
    foreach ($counted as $k => $v) {
        if ($v > 1) {
            for ($i = $v; $i > 0; $i--)  {
                echo $k;
            }
        }
    }
?>

Hiea

php

<?php
    $array = [2,3,4,5,3,7,2,2];
    
    $buffer = [];
    
    foreach ($array as $k => $v) {
        $found = false;
        
        foreach ($buffer as $sk => $sv) {
            if ($v == $sv) {
                $found = true;
            }
        }
        
        if (!$found) {
            $buffer[] = $v;
        }
    }
    
    foreach ($buffer as $k => $v) {
        echo $v;
    }
?>

Sort array

php

<?php

$array = array(4, 6, -2, 1, 3, 90, 0, 9, 8, 7, 5);
$newarray = array();
$x = 0;
$arraysize = sizeof($array);

echo "\nOld "; print_r($array); echo "\n";

// get an array to loop over all the numbers in the array, accounting for changes in length
foreach ($array as $not_needed) {
    // set our original lowest to infinity so that everything is smaller than it
    $lowest = INF;
    // loop through all the array members (again) to find the lowest
    foreach ($array as $arraymember){
        // if the current member is lower than the lowest one so far, make it the lowest
        if ($lowest > $arraymember){
            $lowest = $arraymember;
        } else {};
    }
    $key = array_search($lowest, $array);
    unset($array[$key]);
    $newarray[] += $lowest;
}

// echo the whole array
echo "\nNew "; print_r($newarray); echo "\n";

?>

Execute PHP Online

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<form action="">
    <input type="text" name="uname" value="">
</form>    
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Execute PHP Online

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>
</body>
?php
</bash
</php
</title>
</?php> php scipts </php>
print"hello world"
"hello world"*100
print.numpy as np
select numbers from 1 to 100 
if(1<100)</100>
    or else(if 1==100)
    </body> <title> </>
    print the data and to execute from the list given below
    sql={"name","age","sex"}
    sql={"subham","21","male"}
    "select* from users"
    

Execute PHP Online

php

<?php
$txt = "J'apprends à coder"; //chaine initiale (non modifiée)
$r = "CodeR"; //schéma de recherche

//renvoie NULL si pas d'occurences...
$new =  preg_filter("/$r/i", 'programmer' , $txt);
echo $new ."\n";

//renvoie chaine de départ si 0 occurences trouvées
echo preg_replace("/$r/", 'programmer' , $txt) ."\n";

//Recherche schéma au niveau d'un tableau
$r = '/^[^Em]/i'; $r = '/i.$/';
$tab = ['Emeline', 'Emmanuel', 'Charlie', 'Melvil', 'Emric'];

$res = preg_grep($r, $tab);
print_r($res);

//Eclatement cdc en tableau selon schéma de recherche
$r = "/\s/";
$res = preg_split($r, $txt);
print_r($res);

//QUANTIFIEuRS
$r = '/e.?/';
//toutes occurences de e suivies de n'importe quel caractère
preg_match_all($r, $txt, $res); print_r($res);

$r = '/^j/i';
var_dump( preg_match($r, $txt) );

$r = '/s(=?\sà\s)/';
//true si $txt contient s suivi ' à '
var_dump( preg_match($r, $txt) );

$r = '/p{2}/';
//true si $txt contient 2p consécutifs
var_dump( preg_match($r, $txt) );

//on veut un e ou E non suivi d'un m:
$r = '/e(?!m)/i';
print_r( preg_grep($r, $tab) );













Execute PHP Online

php

<?php
$txt = "J'apprends à coder"; //chaine initiale (non modifiée)
$r = "CodeR"; //schéma de recherche

//renvoie NULL si pas d'occurences...
$new =  preg_filter("/$r/i", 'programmer' , $txt);
echo $new ."\n";

//renvoie chaine de départ si 0 occurences trouvées
echo preg_replace("/$r/", 'programmer' , $txt) ."\n";

//Recherche schéma au niveau d'un tableau
$r = '/^[^Em]/i'; $r = '/i.$/';
$tab = ['Emeline', 'Emmanuel', 'Charlie', 'Melvil', 'Emric'];

$res = preg_grep($r, $tab);
print_r($res);

//Eclatement cdc en tableau selon schéma de recherche
$r = "/\s/";
$res = preg_split($r, $txt);
print_r($res);

//QUANTIFIEuRS
$r = '/e.?/';
//toutes occurences de e suivies de n'importe quel caractère
preg_match_all($r, $txt, $res); print_r($res);

$r = '/^j/i';
var_dump( preg_match($r, $txt) );

$r = '/s(=?\sà\s)/';
//true si $txt contient s suivi ' à '
var_dump( preg_match($r, $txt) );

$r = '/p{2}/';
//true si $txt contient 2p consécutifs
var_dump( preg_match($r, $txt) );









Execute PHP Online

php

<?php


for ($counter= 1 ;$counter <= 30;$counter++){
    
    echo "hello $counter\n";
}

Execute PHP Online

php

<?php




$flo = 6;
while ($flo <= 23) 


/* the displayed value is flo. System will display all true values via statement scho*/
{
    echo $flo;
    $flo++; 
    
    
}


?>

gggg

php

<html>
<head>
<title>Online PHP Script Execution</title>
</head>
<body>
<?php
   echo "<h1>Hello, PHP!</h1>\n";
?>
</body>
</html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.