PHP basic array value solution

Source: Internet
Author: User
PHP basic array value array 1 & nbsp; (& nbsp; [0] & nbsp ;=& gt; & nbsp; company & nbsp; [1] & nbsp ;=& gt; & nbsp; online & nbsp; [2] & nbsp ;=& gt; & nbsp; call & nbsp; [3] & nbsp ;=& gt; & nb PHP base array values
Array 1 ([0] => company [1] => online [2] => call [3] => banner [4] => archive)
Array 2 ([0] => company [1] => banner [2] => archive [3] => logo [4] => movie [5] => product)

How can I obtain the existing array 1, 2?
Array 3 ([0] => online [1] => call)
Array 4 ([0] => logo [1] => movie [2] => product) php basic array value
------ Solution --------------------
$a1 = array('company', 'online', 'call', 'banner', 'archive'); 
$a2 = array('company', 'banner', 'archive', 'logo', 'movie', 'product');
 
print_r(array_diff($a1, $a2));
print_r(array_diff($a2, $a1));
Array
(
[1] => online
[2] => call
)
Array
(
[3] => logo
[4] => movie
[5] => product
)

------ Solution --------------------

$ar1 = array('company', 'online', 'call', 'banner', 'archive'); 
$ar2 = array('company', 'banner', 'archive', 'logo', 'movie', 'product');
$ar3=array_slice($ar1,1,2);
$ar4=array_slice($ar2, 3);
print_r($ar3);
print_r($ar4);

------ Solution --------------------
The two upstairs have the same results, but their ideas are completely different.
#1. difference set
#2 obtain the clip
LZ did not clarify the purpose, so you should find out your needs when selecting ......
------ Solution --------------------
Thank you for sharing...
------ Solution --------------------
I don't know your intention
------ Solution --------------------
What does lz mean? Does it match different companies?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.