Php ternary operator expression help

problem description

A judgment about the data removes the value from the array if it is empty, and passes the MD5 encrypted character value to the value if it is not empty.

for example, an array of $data has $data ["pass"]. If $data [" pass"] is empty, unset () is dropped, and if it is not empty, $data ["pass"] = md5 ($data [" pass"]).

how can I use a ternary expression instead of if to judge? Ask for expert advice.

Mar.29,2021

has just been tested. Unset cannot be used in ternary expressions. Use if


honestly.

for example, a scenario, ha, is a scenario in which the password is changed when the user's information is changed.
use the original if you don't fill it in, then use the new one and encrypt it with hash

$data['password'] = !empty($data['password']) ? Hash::make($data['password']) : $row['password'];

this way determines that if the password is not empty, encrypt it, otherwise use the old password!

according to your needs
should be usable

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bb12-2c2bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bb12-2c2bb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?