English 中文(简体)
• 如何将两个阵列合并到综合点?
原标题:how to combine two arrays in php?

我有一个阵列。 例如:

array( a => abc , b => pqr , c => xyz );

fron this i have encoded the key c now i am getting encoded value for this key.

接下来需要将这种编码价值替换成编码钥匙的原始价值......

举例说,这种潜在产出如下:

array( a => abc , b => pqr , c =>H162);

请任何人帮助我。

问题回答

只是给阵列的要素c分配价值。 e.g.

$arr = array( a => abc , b => pqr , c => xyz );
print_r($arr);
$arr[ c ] =  H162 ;
print_r($arr);

阵列——一个或多个阵列

if you just want to change the value of c and you know the key, you can simply call something like this

$your_array[ c ] = NEW_VALUE

但是,这与组合阵列毫不相干。 如果将2个阵列合并起来,请看

我认为,这是你努力做到的:

$array1 = array( a => abc , b => pqr , c => xyz );
$array2 = array( xyz => test ); 
foreach($array1 as $key=>$element){
    if(array_key_exists($element, $array2)){
       $array1[$key] = $array2[$element]; 
    } 
}

非常宽泛的问题。 我举了一个有数字的例子,有几种编码/编码方法。

第一,界定你的编码/编码功能。 (说明:在这一例子中,一) 工作数量积极。 你可以写上你自己的扼杀方法。 当你查阅你的物品时,你必须始终知道价值是否编码,因此,我们总是代表编码编号为负数,而我们假设的是负数。 (如用“0”和“1”等编码的插图,可以预示正常方位。) 还有其他方法。

//Very simple functions, should be complex functions.
function encode($x) { return - $x * 2; }
function decode($x) { return - $x / 2; }

现在想象着一个阵列:

$arr = array( a =>123, b =>456, c =>789);

编号:

$arr[ c ] = encode($arr[ c ]);

......或将所有项目列入贵国的表格:

foreach($arr as $key=>$val)
   $arr[$key] = encode($arr[$key]);

进入阵列成员:

function getArrayMember($key)
{
if ($arr[$key] < 0)            //This is an encoded number...
    return decode($arr[$key]); //...decode it.
else                           //Normal numbers...
    return $arr[$key];         //...return as is.
}

这个数字是多少。 你们可以实施或找到合适的扼杀/dec方法。





相关问题
Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Using Java PDFBox library to write Russian PDF

I am using a Java library called PDFBox trying to write text to a PDF. It works perfect for English text, but when i tried to write Russian text inside the PDF the letters appeared so strange. It ...

what is encoding in Ajax?

Generally we are using UTF-8 encoding standard for sending the request for every language. But in some language this encoding standard is not working properly,then in that case we are using ISO-8859-1....

Encoding of window.location.hash

Does window.location.hash contain the encoded or decoded representation of the url part? When I open the same url (http://localhost/something/#%C3%BC where %C3%BCtranslates to ü) in Firefox 3.5 and ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

热门标签