Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
echo "題目一\n";
$ABC="php is great";
echo strtoupper($ABC)."\n";
echo str_replace("php is great","PHP IS AWESOME",$ABC)."\n";
echo "題目二\n";
$students = ["Ethan Caldwell", "Lucas Harper", "Mason Bennett"];
function getSingleNameLength(string $name)
{
$nameNoSpace = str_replace(" ", "", $name);
return strlen($nameNoSpace) ;
}
function getStudentsNameLength(array $students)
{
$Length=[];
foreach($students as $Sname)
{
$Length[$Sname]=getSingleNameLength($Sname);
}
Return $Length;
}
function appendStudentCount(array $studentsNameLength)
{
$SNL=getStudentsNameLength($studentsNameLength);
$SNL['student_count']=count($SNL);
Return $SNL;
}
print_r (appendStudentCount($students));
echo "題目三\n";
$schema = 'https';
$host = 'example.com';
$path = 'v1/api/doge/transactions';
$query =['page' => 1, 'per_page' => 15];
$queryString = http_build_query($query);
$fullUrl = sprintf("%s://%s/%s?%s", $schema, $host, $path, $queryString);
echo $fullUrl;