test
This commit is contained in:
36
app/CustomFuncPao.php
Normal file
36
app/CustomFuncPao.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
function showarray($array)
|
||||
{
|
||||
echo '<pre>' . json_encode($array, JSON_PRETTY_PRINT) . '</pre>';
|
||||
};
|
||||
|
||||
function isKeyPresent($array, $key)
|
||||
{
|
||||
foreach ($array as $item) {
|
||||
if (isset($item->key) && $item->key === $key) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getValueByKey($array, $key)
|
||||
{
|
||||
foreach ($array as $item) {
|
||||
if (isset($item->key) && $item->key === $key) {
|
||||
return $item->value;
|
||||
}
|
||||
}
|
||||
return null; // If key is not found
|
||||
}
|
||||
|
||||
// Funzione per aggiornare il valore di un certo key in un array di oggetti
|
||||
function updateValueByKey(&$array, $key, $newValue) {
|
||||
foreach ($array as &$item) {
|
||||
if ($item['key'] === $key) {
|
||||
$item['value'] = $newValue;
|
||||
break; // Se trova il key, termina il loop
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user