Home Backend Development PHP Tutorial php怎么取得变量中的数组并赋值到变量中

php怎么取得变量中的数组并赋值到变量中

Jun 13, 2016 am 10:42 AM
content query quot storage update

php如何取得变量中的数组并赋值到变量中?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->        当 $products = 100=1时                我怎么执行以下动作:(此时有 1 个执行语句)                 运行时是这样的   $db->query("UPDATE {$_pre}content SET storage=storage-1 WHERE id='100'");                                当 $products = 100=1,104=3 时                我怎么执行以下动作:(此时有 2 个执行语句)                  运行时是这样的   $db->query("UPDATE {$_pre}content SET storage=storage-1 WHERE id='100'");                         $db->query("UPDATE {$_pre}content SET storage=storage-3 WHERE id='104'");                            当 $products = 100=1,104=8,204=4,243=2,690=1 时                我怎么执行以下动作:(此时有 5 个执行语句)                  运行时是这样的   $db->query("UPDATE {$_pre}content SET storage=storage-1 WHERE id='100'");                         $db->query("UPDATE {$_pre}content SET storage=storage-8 WHERE id='104'");                         $db->query("UPDATE {$_pre}content SET storage=storage-4 WHERE id='204'");                         $db->query("UPDATE {$_pre}content SET storage=storage-2 WHERE id='243'");                         $db->query("UPDATE {$_pre}content SET storage=storage-1 WHERE id='690'");
Copy after login




------解决方案--------------------
PHP code
$products ='100=1,104=8,204=4,243=2,690=1';foreach(explode(',',$products) as $v){       $t=explode('=',$v);       $db->query("UPDATE {$_pre}content SET storage=storage-{$t[1]} WHERE id='{$t[0]}'");}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Fix: Google Chrome update check failed with error code 3: 0x80040154 Fix: Google Chrome update check failed with error code 3: 0x80040154 Apr 13, 2023 pm 05:46 PM

Google Chrome is one of the most popular browsers in the world and many users prefer to use it as the default browser on their Windows PCs. Chrome offers a wide range of features that make the browsing experience enjoyable and effortless, and therefore, it remains one of the most trusted browsers. But just like any other browser, even Chrome has its own shortcomings, and it's equally prone to bugs and glitches when you need it most. One such error is Error Code 3: 0x80040154, which occurs while checking for Google Chrome updates. The error message reads "An error occurred while checking for updates. The update check failed to start (Error code 3: 0x80080005) or (Error

How to enable/disable VS Code automatic updates How to enable/disable VS Code automatic updates Apr 28, 2023 am 09:28 AM

If you are using Visual Studio Code (VSCode) and thinking about how to disable its automatic software updates and how to disable the automatic updates of its extensions, then read this article. If you don't use VSCode often, open the editor after a long period of time and want to enable automatic updates, this article will also guide you in doing so. Let us discuss in detail the different ways to enable or disable VSCode automatic updates. Table of Contents Method One: Use Settings to Enable/Disable VSCode Automatic Updates Step 1: Open VS Code and click the gear-shaped symbol in the lower left corner. Step 2: Click Settings in the list that appears. Step 3: Type update in the search bar and hit enter. Find Updates: Pattern 4

Solution to high CPU usage of Microsoft compatibility telemetry Solution to high CPU usage of Microsoft compatibility telemetry Mar 16, 2024 pm 10:16 PM

When we use the win10 system, we sometimes encounter situations where the computer becomes stuck. Then when we check the background process, we find that a Microsoftcompatibilitytelemetry process takes up a particularly high amount of resources. So what is going on? Users can try to uninstall the third-party protection software and then try a clean boot to operate. Let this site carefully introduce to users the solution to the high CPU usage of Microsoftcompatibilitytelemetry. Solution to the high CPU usage of Microsoftcompatibilitytelemetry Method 1: Try after uninstalling the third-party protection software

KDE Plasma 6.1 brings many enhancements to the popular Linux desktop KDE Plasma 6.1 brings many enhancements to the popular Linux desktop Jun 23, 2024 am 07:54 AM

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

How to reorder multiple columns in Power Query via drag and drop How to reorder multiple columns in Power Query via drag and drop Mar 14, 2024 am 10:55 AM

In this article, we will show you how to reorder multiple columns in PowerQuery by dragging and dropping. Often, when importing data from various sources, columns may not be in the desired order. Reordering columns not only allows you to arrange them in a logical order that suits your analysis or reporting needs, it also improves the readability of your data and speeds up tasks such as filtering, sorting, and performing calculations. How to rearrange multiple columns in Excel? There are many ways to rearrange columns in Excel. You can simply select the column header and drag it to the desired location. However, this approach can become cumbersome when dealing with large tables with many columns. To rearrange columns more efficiently, you can use the enhanced query editor. Enhancing the query

React Query database plug-in: how to import and export data React Query database plug-in: how to import and export data Sep 26, 2023 pm 05:37 PM

ReactQuery database plug-in: Methods to implement data import and export, specific code examples are required. With the widespread application of ReactQuery in front-end development, more and more developers are beginning to use it to manage data. In actual development, we often need to export data to local files or import data from local files into the database. In order to implement these functions more conveniently, you can use the ReactQuery database plug-in. The ReactQuery database plugin provides a series of methods

How to use UPDATE statement in SQL How to use UPDATE statement in SQL Jun 02, 2023 pm 09:13 PM

SQLUPDATE statement The Update statement is used to modify the data in the table. The syntax is as follows: UPDATE table name SET column name = new value WHERE column name = certain value "Person" table: LastNameFirstNameAddressCityGatesBillXuanwumen10BeijingWilsonChamps-Elysees Update a column in a certain row UPDATEPerson SETFirstName="Fred" WHERELastName="Wilson" Result: LastNa

In-depth exploration of the usage details of UPDATE in MySQL In-depth exploration of the usage details of UPDATE in MySQL Oct 11, 2022 pm 07:32 PM

In MySQL, you can use the UPDATE statement to modify and update data in one or more tables. The following article will help you explore the details of the use of UPDATE in MySQL. I hope it will be helpful to you.

See all articles