Jump to content

[SOLVED] array strtolower


homer.favenir

Recommended Posts

hi,

can anyone please help me how to change the case of an array to lower.

 

my script is

<?php
$a = array(cot01,COT02,cot03);
$b = array(cot01,COT02,COT03);
$diff = array_diff($a, $b);
$diff2 = array_diff($b, $a);
$union =  array_merge($diff,$diff2);
print_r($union);

?>

 

i want to strtolower the $a and $b, when i compare them the uppercase is different

from lowercase eventhough they have the same word

 

thanks

 

Link to comment
Share on other sites

<?php

$a = array(cot01,COT02,cot03);
$b = array(cot01,COT02,COT03);
$a = array_map('strtolower', $a);
$b = array_map('strtolower', $b);
$a=array_diff($a,$b);
$union = array_merge($a,$b);
print_r($union);

?>

 

 

array array_map  ( callback $callback  , array $arr1  [, array $...  ] )

 

array_map() returns an array containing all the elements of arr1 after applying the callback function to each one. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()

 

 

Array

(

    [0] => cot01

    [1] => cot02

    [2] => cot03

)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.