//写入缓存
$menu_query = exequery( $connection, " SELECT ct.id as tid, ct.type_name , mb.id, mb.cookname,
mb.price, mb.description, mb.pinyin FROM cook_type ct LEFT JOIN menubook mb ON ct.id = mb.cook_type WHERE
mb.id = ".$cook_id);
$menu_result = mysql_fetch_array( $menu_query );
//echo "菜单id:".$cook_id.";分类id:".$menu_result[tid];exit;
//本次菜单
$row[mid] = $cook_id;
$row[menu_name] = $cook_name;
$row[description] = $description;
$row[menu_price] = $cook_price;
$row[pinyin] = ChangeToPinyin(iconv("utf-8","gb2312",$cook_name),1);
if( file_exists( "./menubook.php") )
{
require_once( "./menubook.php" );
}
if( is_array( $menu_cache) && !empty( $menu_cache) )
{
$classnum = count( $menu_cache );
$unmatchnum = 0;
for ( $i=0; $i
{
if( $menu_result[tid] != $menu_cache[$i][tid] )
{
$unmatchnum++;
continue;
}
else //找到分类 , 继续寻找菜品的缓存是否存在
{
$cartenum = count( $menu_cache[$i][list]);
$unmarrynum = 0;
for ( $j=0; $j
{
if ( $menu_cache[$i][list][$j][mid] != $cook_id )
{
$unmarrynum++;
continue;
}
else //修改菜单
{
$menu_cache[$i][list][$j][menu_name] = $cook_name;
$menu_cache[$i][list][$j][description] = $description;
$menu_cache[$i][list][$j][menu_price] = $cook_price;
$menu_cache[$i][list][$j][pinyin] = $row[pinyin];
}
}
//新添加的菜单
if( $cartenum == $unmarrynum )
{
$menu_cache[$i][list][] = $row;
}
}
}
//未找到分类
if ( $unmatchnum == $classnum )
{
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[list][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数组的生成
$type_row[tid] = $menu_result[tid];
$type_row[type_name] = $menu_result[type_name];
$type_row[list][0] = $row;
$menu_cache[] = $type_row;
}
//print_r( $menu_cache );
//写入文件
ob_start();
var_export( $menu_cache );
$content = ob_get_contents( );
ob_end_clean();
$filename = "menubook.php";
$fp = fopen( $filename, "w" );
fwrite( $fp, "" );
fclose( $fp );
二、添加菜单,写入缓存
$str=ChangeToPinyin(iconv("utf-8","gb2312",$cook_name),1);
$query_cook_add="insert into menubook(cookname,price,cook_type,description,pinyin) values(".$cook_name.",".$cook_price.",".$cook_type.",".$description.",".$str.")";
$cursor_cook_add=exequery($connection,$query_cook_add);
$cook_id = mysql_insert_id();
$menutype_query = exequery( $connection, " SELECT type_name FROM cook_type WHERE id = ".$cook_type);
$menutype_result = mysql_fetch_array( $menutype_query );
//本次菜单
$row[mid] = $cook_id;
$row[menu_name] = $cook_name;
$row[description] = $description;
$row[menu_price] = $cook_price;
$row[pinyin] = $str;
if( file_exists( "./menubook.php") )
{
require_once( "./menubook.php" );
}
if( is_array( $menu_cache) && !empty( $menu_cache) )
{
$classnum = count( $menu_cache );
$unmatchnum = 0;
for ( $i=0; $i
{
if( $cook_type != $menu_cache[$i][tid] )
{
$unmatchnum++;
continue;
}
else //找到分类 ,添加改产品菜品的缓存
{
$menu_cache[$i][list][] = $row;
}
}
if( $classnum == $unmatchnum ) //未找到分类
{
$type_row[tid] = $cook_type;
$type_row[type_name] = $menutype_result[type_name];
$type_row[list][0] = $row;
$menu_cache[] = $type_row;
}
}
else { //数组的生成
$type_row[tid] = $cook_type ;
$type_row[type_name] = $menutype_result[type_name];
$type_row[list][0] = $row;
$menu_c

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。


Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

EditPlus versi Cina retak
Saiz kecil, penyerlahan sintaks, tidak menyokong fungsi gesaan kod

Dreamweaver Mac版
Alat pembangunan web visual

ZendStudio 13.5.1 Mac
Persekitaran pembangunan bersepadu PHP yang berkuasa

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

mPDF
mPDF ialah perpustakaan PHP yang boleh menjana fail PDF daripada HTML yang dikodkan UTF-8. Pengarang asal, Ian Back, menulis mPDF untuk mengeluarkan fail PDF "dengan cepat" dari tapak webnya dan mengendalikan bahasa yang berbeza. Ia lebih perlahan dan menghasilkan fail yang lebih besar apabila menggunakan fon Unicode daripada skrip asal seperti HTML2FPDF, tetapi menyokong gaya CSS dsb. dan mempunyai banyak peningkatan. Menyokong hampir semua bahasa, termasuk RTL (Arab dan Ibrani) dan CJK (Cina, Jepun dan Korea). Menyokong elemen peringkat blok bersarang (seperti P, DIV),
