From the screenshot you can see, i am showing the google map using shortcode
[acf field="maps"]

Simple Web Development tips & spiritual observations
From the screenshot you can see, i am showing the google map using shortcode
[acf field="maps"]

Code:
<?php
$name= array("Tom", "Jon","Rowan","Jim","Harry","Rasha");
echo "Main Array";
echo "<br>";
print_r($name);
echo "<br>";
echo "slice upto 3";
echo "<br>";
$name1=array_slice($name,3);
print_r($name1);
echo "<br/>";
echo "Keeping Key same: slice 3,2";
$name2=array_slice($name,3,2,true);
print_r($name2);
echo "<br/>";
echo "slice 3,-1<br>";
$name3= array_slice($name,3,-1);
print_r($name3);
echo "<br>slice 3,-2<br>";
$name3= array_slice($name,3,-2);
print_r($name3);
echo "<br>slice -3,-2<br>";
$name3= array_slice($name,-3,-2);
print_r($name3);
echo "<br>slice -3,-1<br>";
$name3= array_slice($name,-3,-1);
print_r($name3);
echo "<br>slice -3,1<br>";
$name3= array_slice($name,-3,2);
print_r($name3);
?>
Code:
<?php
function functionAdd($n) {
$result = 0 ;
if(gettype($n)!='integer'){
echo "Invalid type";
}
for($i=1;$i<=$n;$i++){
$result+= $i;
}
echo $result.gettype($n);
}
functionAdd(5);
echo "<br>";
functionAdd("haha");
?>
Output:
15integer
Invalid type
CODE:
<?php
$fname = "Tom";
$lname = "Hanks";
$newFname ;
$fname = $newFname ?? $fname;
echo $fname;
$newFname= "Jon";
$fname = $newFname ?? $fname;
echo "<br>";
echo $fname;
?>
Code:
<?php
class StudentInfo{
public $name;
public $age;
private $mobileNum;
public function setMobileNum($mobileNum){
$this->mobileNum=$mobileNum;
}
public function getMobileNum(){
return $this->mobileNum;
}
}
$student = new StudentInfo();
$student -> name ="Tommy Jones";
$student -> age =45;
print_r($student);
$student->setMobileNum('11111111');
echo "<br>";
print_r($student);
$jsonEncoded=json_encode($student);
echo "<br>";
print_r($jsonEncoded);
$jsonDecoded=json_decode($jsonEncoded);
echo "<br>";
print_r($jsonDecoded);
$jsonDecodedArray=json_decode($jsonEncoded,true);
echo "<br>";
print_r($jsonDecodedArray);
?>
Only Public ones will be converted
Code:
<?php
class studentInfo{
public $name;
public $age;
private $mobileNum;
public function setMobileNum($mobileNum){
$this->mobileNum=$mobileNum;
}
public function getMobileNum(){
return $this->mobileNum;
}
}
$student = new studentInfo();
$student->name= "Tom hanks";
$student->age = 45;
$student->setMobileNum('11111111');
//echo $student->getMobileNum();
echo json_encode($student);
?>
CODE:
<?php
$studentNum=0;
if(isset($studentNum)){
echo "value is set ";
}else{
echo "value not set";
}
echo "<br>";
if(empty($studentNum)){
echo "value is empty";
}else{
echo "value not empty";
}
echo "<br>";
if(isset($studentNum) && (is_numeric($studentNum) || $studentNum !='')){
echo "there is value and not empty";
}else{
echo " not set or empty";
}
?>
OUTPUT:
value is set
value is empty
there is value and not empty
CODE:
<?php
/*** remove key and data from associative array PHP */
$studentInfo =["name"=>"Tomy Jason","age"=>45,"sex"=>"Male"];
print_r($studentInfo);
unset($studentInfo["sex"]);
echo "<br>";
print_r($studentInfo);
?>
Code:
<?php
$customer= [
"name"=>"Tommy Jason",
"age" => 45,
"sex" => "Male",
"location" => "USA"
];
print_r($customer);
echo "Serialized: <br>";
$serializedCustomer =serialize($customer);
echo $serializedCustomer;
echo "<br>";
echo "Unserialized: <br>";
$unserializedCustomer =unserialize($serializedCustomer);
print_r($unserializedCustomer);
echo "<br>";
echo "JSon Encoded<br>";
echo $jsonEncoded = json_encode($customer);
echo "<br>";
echo "Json Decoded --converted to object <br>";
$jsonDecoded= json_decode($jsonEncoded);
print_r($jsonDecoded);
echo "<br>Json Decoded --converted to Array <br>";
$jsonDecoded= json_decode($jsonEncoded,true);
print_r($jsonDecoded);
echo "<br>";
?>
Code:
<?php
$students=[
'12'=>'Tom',
'13'=>'Shib',
'14'=>[
'12'=>'Tom Spanish',
'13'=>'Shib Spanish'
]
];
var_dump($students);
echo "<br>";
print_r($students);
echo "<br>";
echo $students["14"]["13"];
echo "<br>";
$food=array(
"vegetables" => "tomato,potato",
"frutis" => "apple, banana",
"drinks" => array(
"soft"=>"coke,fanta",
"beverage" => "x,y,z",
)
);
print_r($food);
echo "<br>";
echo $food["drinks"]["soft"];
?>