Question : php function parameter type

can someone show me how to call this function from a php page?  I'm unsure what to pass in for the txtProperties parameter.  I want to use the below to read in a file located in /testdir/test.properties.  So the goal is to read in the properties file and then get the value for one of the key value pairs.  

example of testdir/test.properties
value1=testing

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
function parse_properties($txtProperties) {
		$result = array();
		$lines = split("\n", $txtProperties);
		$key = "";
		$isWaitingOtherLine = false;
		foreach ($lines as $i => $line) {
			if (empty($line) || (!$isWaitingOtherLine && strpos($line, "#") === 0))
				continue;

			if (!$isWaitingOtherLine) {
				$key = substr($line, 0, strpos($line, '='));
				$value = substr($line, strpos($line, '=')+1, strlen($line));
			}
			else {
				$value .= $line;
			}	

			/* Check if ends with single '\' */
			if (strrpos($value, "\\") === strlen($value)-strlen("\\")) {
				$value = substr($value,0,strlen($value)-1)."\n";
				$isWaitingOtherLine = true;
			}
			else {
				$isWaitingOtherLine = false;
			}

			$result[$key] = $value;
			unset($lines[$i]);
		}

		return $result;
	}

      

Answer : php function parameter type

If those are the data stored in the ini file, after executing something like the stippet of this post you will obtain the following:

$props['image1.jpg.album'] => 'album1'
$props['image1.jpg.caption'] => 'pic 1 caption'

and so on... I think that works for your porpuses...

Take into account that you can name a PHP index with almost all of the special chars (in this case the period/full stop symbol "." wich references to its object origin)...
1:
$props = parse_ini_file('testdir/test.properties', false);
Random Solutions  
 
programming4us programming4us