473,480 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Vedere se due array sono lo stesso array

Ho questa funzione che prende due array: aggiorna il primo (aggiungendo,
togliendo o modificando elementi) e poi aggiorna anche il secondo, ma solo
se e' un array diverso dal primo:

function Aggiorna(&$a, &$b)
{
if( $a e' lo stesso di $b ){
aggiorna solo $a
} else {
aggiorna $a
aggiorna $b
}
}
Ad esempio,

$a = array(1, 2, 3);
$b = array(1, 2, 3);
$c = &$a;

Aggiorna($a, $b); # aggiorna $a e $b
Aggiorna($a, $c); # aggiorna solo $a, dato che $c e' la stessa cosa

Problema: come faccio a sapere se due array sono lo stesso array? Cioe',
in altre parole, come faccio a sapere se le modifiche all'uno si
riflettono anche all'altro?

Non e' facile come sembra. Notare che

$a == $b

e

$a === $b

danno entrambi TRUE sebbene gli array siano distinti.

Ciao,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

Sep 16 '05 #1
0 1195

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2783
by: Reed Law | last post by:
I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' => '/youth/pics/Member pics/', 'text' => 'Member pics', ),...
2
2753
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
575
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
0
1551
by: sjaak538 | last post by:
Hello I've a question about printing complex array's with print_r $xmlC->obj_data I get this example bellow But can anybody give me one example on how to echo $xmlC->obj_data; I try'd with...
3
2957
by: Paul Kirby | last post by:
Hello All I am trying to update me code to use arrays to store a group of information and I have come up with a problem sorting the multiple array :( Array trying to sort: (7 arrays put into...
15
5153
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
5
2855
by: Nico | last post by:
Hello folks, I am currently storing a set of objects inside an array, $itemlist = array(); $itemlist = new item("myitem"); //... and I am looking to develop a search function, which...
41
2180
by: puzzlecracker | last post by:
Given an array of size n and populated with consecutive integers from 1 to n i.e. in random order. Two integers are removed, meaning zero is placed in their places. Give O (n) efficient algorithm...
1
1799
by: mario.lat_ | last post by:
Salve, Vorrei usare un wiki (scritto in PHP). Sono orientato su Dokuwiki ma mi hanno parlato molto bene anche di TWiki. Qualcuno di voi lo conosce? quali sono le differenze fra i due? Un...
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.