• Nov 19, 2022 •CodeCatch
0 likes • 0 views
<?php $json ='{"id":1,"name":"foo","interest":["wordpress","php"]}'; $obj=json_decode($json); echo $obj->interest[1]; //prints php ?>
• Nov 18, 2022 •AustinLeath
0 likes • 1 view
<?php $listOfFiles = glob("*.{jpg,png,gif,tiff,jpeg}", GLOB_BRACE); echo 'images = []; '; for($x = 0; $x <= count($listOfFiles)-1; $x++) { echo "images[" . $x . "] =" . '"' . $listOfFiles[$x] . '"' . "; "; } ?>
<?php /* * @param string $file Filepath * @param string $query Needed information (0 = width, 1 = height, 2 = mime-type) * @return string Fileinfo */ function getImageinfo($file, $query) { if (!realpath($file)) { $file = $_SERVER["DOCUMENT_ROOT"] . $file; } $image = getimagesize($file); return $image[$query]; } ?>
0 likes • 4 views
<?php header('Content-Type:text/html'); $jsonData = json_decode(file_get_contents("names.json")); $namesArray = array(); foreach($jsonData as $data) { $namesArray[] = $data; } for($i = 0; $i < 64000; $i++) { echo 'D.add_edge("'. $namesArray[array_rand($namesArray)] . '", "' . $namesArray[array_rand($namesArray)]. '")'; echo "<br>"; } ?>
<?php $username = "Austin Leath -_#"; $username_err = "no error"; if(preg_match('/[^a-z_\-0-9]/i', $string)) { $username_err = "Username can only contain alphanumeric characters, dashes, and underscores."; } echo $username_err ?>
0 likes • 2 views
<?php function getFileExtension($file) { return end(explode(".", $file)); } ?>