populating on the basis of array elements in php

Posted by Avinash on Stack Overflow See other posts from Stack Overflow or by Avinash
Published on 2012-10-22T10:37:47Z Indexed on 2012/10/22 11:00 UTC
Read the original article Hit count: 138

Filed under:
|
|

This is my code.

        if(in_array("1", $mod)){ 
        $res=array('First Name','Insertion','Last Name','Lead Country');}

       if(in_array("2", $mod)){ 
        $res=array('Landline No:','Mobile No:','Lead Country');}

        if(in_array("3", $mod)){ 
        $res=array('City','State','Country','Lead Country');}

        if(in_array("4", $mod)){ 
        $res=array('Email','Lead Country');}

        return $res;

Upto this it works fine. But if the array contains more than one value say (1,3) I need to return both results of 1 and 3.

eg: if the array is like this

    array([0]=>1 [1]=>3)

then

    $res=array('First Name','Insertion','Last Name','City','State','Country','Lead Country') 

But if there are 2 lead country only one should be displayed how to do this? Pls help me.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays