Possible Duplicate:
PHP split alternative?
I am a beginner in php,
Basically I am trying to extrat value from a line
the line format is key:value
The value may possibly contain :
So I want to divide it into two parts such that I get right and left side of first occurance of :
There is a function I have written because this will execute per line of a file
/**
* Returns value of the key if its available in line
* example line
* somekey: someva:lue
* @param type $line pass full line
* @param type $key pass the key
* @return type someva:lue
*/
function extractValue($line, $key){
$value = null;
$value_array = split(":", $line);
if(count($value_array)== 2)
{
if($value_array[0] == $key)
$value = $value_array[1];
}
return $value;
}
I just started coding it today in netbeans anf get the following warning that split is deprectaed etc
Deprecated: Function split() is deprecated in C:\wamp\www\myprojects\PhpProject1\upload_log.php on line 92
I am not very familiar with php , could you suggest an alternate function ? basically I want the line into two parts key:value want to get value given a line and key
Thanks for help,
Simply:
2 is the maximum number of elements to get, which fits your problem.