在PHP中切片数组(Slicing arrays in PHP)
我怎么能在PHP中使用另一个布尔数组切片数组?
<?php $arr=array(0=>12,1=>'name',2=>1.21,4=>'color'); $select=array(1=>true,2=>true,3=>true,4=>false); //$new=$arr[$select]; ?>
在Python中这很简单,但我也可以在PHP中执行此操作吗?
How could I slice an array with another boolean array in PHP?
<?php $arr=array(0=>12,1=>'name',2=>1.21,4=>'color'); $select=array(1=>true,2=>true,3=>true,4=>false); //$new=$arr[$select]; ?>
In Python this is simple, but can I do this also in PHP?
原文:https://stackoverflow.com/questions/34137757
更新时间:2022-11-28 06:11
最满意答案
这个SQL可能有所帮助:
SELECT table2.id FROM table2 WHERE table2.id NOT IN ( SELECT DISTINCT table1.id FROM table1 )
This SQL may help:
SELECT table2.id FROM table2 WHERE table2.id NOT IN ( SELECT DISTINCT table1.id FROM table1 )
相关问答
更多-
尝试 select ptc.ptc_name, aud.aud_year from ptc_table ptc inner join ada_table ada on ada.ada_ptcid=ptc.ptc_id inner join aud_table aud on aud.aud_id=ada.ada_aud_id try select ptc.ptc_name, aud.aud_year from ptc_table ...
-
使用jQuery检查HTML页面中的特定表ID和元素(Check HTML page for particular table ID and element using jQuery)[2023-09-11]
$(function() { // after dom ready if($('table#main_table').length){ alert('exists'); } }) $(function() { // after dom ready if($('table#main_table').length){ alert('exists'); } }) -
加入一个子选择,确定用户是否在该组中。 即,以下内容将为您提供出价和一个字段,说明是否找到了用户。 SELECT auction_bids.*, IF(Sub1.auction_bid_item_id IS NULL, 'User not found', 'User found') FROM auction_bids LEFT OUTER JOIN ( SELECT DISTINCT auction_bid_item_id FROM auction_bids WHERE auc ...
-
Laravel 5.2:DB记录在另一个表中获取和检查id(Laravel 5.2 : DB Records fetch and check id in another table)[2022-01-05]
你为什么不使用连接? TableA::query() ->select("tableA.*, tableB.id as checked") ->leftJoin("tableB","tableA.id","=","tableB.id") ->get(); 因此,如果tableB中没有id ,则checked将为空。 Why don't you use joins? TableA::query() ->select("tableA.*, tableB.id as checke ... -
mysql从一个表中选择all并检查另一个表的ID和状态(mysql select all from one table and check another table for ID and status)[2022-07-19]
为什么要阻止使用连接? 这很简单: SELECT p.*, g.id, g.hol FROM pictures AS p INNER JOIN galleries as g ON g.id = p.gallery_id WHERE p.views > $views AND g.hold <> 1 ORDER BY p.rating(?) DESC LIMIT $index, $pics_per_page; Why do you want to prevent the usage of a join? ... -
使用MySQL join检查另一个表中是否存在特定ID(Check if a particular ID exists in another table or not using MySQL join)[2023-11-02]
您可以使用以下LEFT JOIN来实现此目的,它将为所有正确的表数据提供匹配的右表数据。 SELECT * FROM table_1 LEFT JOIN table_2 on table_1.userId=table_2.userId You can use this following LEFT JOIN for the purpose, It will give all right table data with matched right table data . SELECT * FROM tab ... -
EXISTS是你的朋友 假设您从包含播放器player_ref的表(我的示例中的whatever )中进行player_ref : SELECT * FROM wherever WHERE NOT EXISTS(SELECT 1 FROM PlayerList WHERE player_ref=whatever.player_ref) AND NOT EXISTS(SELECT 1 FROM PlayerListTemp WHERE player_ref=whatever.player_ref) EXI ...
-
尝试在php变量中保存以前的id。 $id = mysql_insert_id(); $sql2="INSERT INTO copies (film_id,format,film_c) VALUES ($id,'VHS','$vhs')"; mysql_query($sql2); $sql3="INSERT INTO copies (film_id,format,film_c) VALUES ($id,'DVD','$dvd')"; mysql_query($sql3); Try saving the p ...
-
这个SQL可能有所帮助: SELECT table2.id FROM table2 WHERE table2.id NOT IN ( SELECT DISTINCT table1.id FROM table1 ) This SQL may help: SELECT table2.id FROM table2 WHERE table2.id NOT IN ( SELECT DISTINCT table1.id FROM table1 )
-
这是网络抓取。 许多语言都有办法做到这一点。 选择最舒适的,但是,美丽的汤库是一个不错的选择。 This is web scraping. Many languages have a way to do this. Pick your most comfortable, however, python w/ the beautiful soup library is a nice choice.