software:php
Table of Contents
How To's
Iterate an associative array (map)
- snippet.php
foreach ($map as $key => $value) { echo "{$key} => {$value} "; print_r($arr); }
Use a lambda to map an array of objects into a string
- snippet.php
$getVideoUrl = function($video) : string { return "<a href='".$video->video_url."'><img src='".$video->thumbnail_url."'/></a>"; }; ... $videoUrls = $listing->videos != null ? implode(",", array_map($getVideoUrl, $listing->videos)) : "";
Getting request parameter and setting values
$_SERVER$_GET- http://max/php-manual/reserved.variables.get.html (technically ALL params on the URL regardless of HTTP verb)
$_POST$_FILES$_REQUEST
// param value is null if missing $getParam = $_GET["paramName"]; $postParam = $_POST["paramName"]; $anyRequestParam = $_REQUEST["paramName"];
String Formatting
Number-to-string Formatting
$nextSkuOrdinal = sprintf("%03d", $row['nextSkuOrdinal']);
software/php.txt · Last modified: 2025/06/11 14:18 by 127.0.0.1
