I have a string, who contains multiple values. A new line is recognised as | symbol. The values between | belong together.
Now, I am trying for example if IKK and Homo sapiens are present in the line, to return the other values in that line (96, NC_000001 , IKK , inhibitor of nuclear factor, IKK = IKKI).
I use explode function for separating the string based on | symbol. But if I use the explode function again now based , symbol. I got again an array. But if I now would look for homo sapiens & IKK and want to return the other values from that same line, I got stuck.
I have the following string:
$var = 'IKK ,Homo sapiens,96, NC_000001 , IKK , inhibitor of nuclear factor,
IKK = IKKI |GAL4 ,Saccharomyces cerevisiae,85588,NC_00114 , GAL4 ,0, GAL81
|TRP ,Influenza HA,0,0,0,0,0|TES,Influenza HA,5,0,TES,0,0';
My code:
function terms($result){
$result = (explode("|",$result));
$final = array_unique($result);
return $final;
}
$test = terms($var);
foreach ($test as $key => $value){
echo "key: $key -- value: $value"."<br \>
";
$res = explode(",",$value);
foreach ($res as $v){
echo "tester: >> $v"."<br \>
";
}
}
I probably should end up with something like this. But I don't find a way to get there. Is it even possible to get this structure?
if ($d[1] == "Homo sapiens" && $d[0] == "IKK"){
$k = $d[2] # 96
$s = $d[3] # NC_000001
}
As end result I would like to save the values 96, NC_000001 , IKK , inhibitor of nuclear factor, IKK = IKKI separately again and again in a separate variable. $number = 96 $acc = NC_000001