比如我有两个数组
A组:10,11,12,13
B组:14,15
想组合成 10|14,11|14,12|14,13|14,10|15,11|15,12|15,13|15
拜谢了 可能会发生三组 四组 比如A组 B组 C组 D组
回复讨论(解决方案)
你这是在求笛卡尔积,精华区有好几个相关讨论
这里再给个版本
$a = array(10,11,12,13);$b = array(14,15);foreach(Descartes($a, $b) as $v) $r[] = join(',', $v);echo join('|', $r);10,14|10,15|11,14|11,15|12,14|12,15|13,14|13,15
function Descartes($d) { if(func_num_args() > 1) $d = func_get_args(); $r = array_pop($d); while($d) { $t = array(); $s = array_pop($d); if(! is_array($s)) $s = array($s); foreach($s as $x) { foreach($r as $y) $t[] = array_merge(array($x), is_array($y) ? $y : array($y)); } $r = $t; } return $r; }
你这是在求笛卡尔积,精华区有好几个相关讨论
这里再给个版本
$a = array(10,11,12,13);$b = array(14,15);foreach(Descartes($a, $b) as $v) $r[] = join(',', $v);echo join('|', $r);10,14|10,15|11,14|11,15|12,14|12,15|13,14|13,15
function Descartes($d) { if(func_num_args() > 1) $d = func_get_args(); $r = array_pop($d); while($d) { $t = array(); $s = array_pop($d); if(! is_array($s)) $s = array($s); foreach($s as $x) { foreach($r as $y) $t[] = array_merge(array($x), is_array($y) ? $y : array($y)); } $r = $t; } return $r; }
谢谢版主,我等会测试下,稍后我再发布个需求,等会您再帮我看看
http://bbs.csdn.net/topics/391860657 大神再帮我看看这个

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Alipay PHP...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor