[Solved] Function does not return value !
Posted: Fri Jun 01, 2012 4:28 am
All the problem that seems to me is, that php does not return the variable. Variable r is correctly created,but not returned.
Code: Select all
#!/usr/bin/php
<?php error_reporting("E_ALL");
// Get part of string defined by starting and ending string
function getPartOfString($string,$startPos,$endPos){
//If no starting string do this
if($startPos==""){echo"test1\n";
$p=explode($endPos,$string);
return$p[0];}
//If no ending string do this
if($endPos==""){echo"test2\n";
$p=explode($startPos,$string);
return$p[1];}
//If both present do this
if($endPos!="" and $startPos!=""){echo"test3\n";
$p=explode($startPos,$string);
$pp=explode($endPos,$p[1]);
$r=$pp[0];
echo"Value to return = $r\n";
return$r;}
}
//reorganise value order insertnion
function getPartOfString2($startPos,$endPos,$string){ getPartOfString($string,$startPos,$endPos);}
//execute command
// return string between gs and zb
echo">".getPartOfString2("gs","zb","549df852pgsf64875621szby8474zu584")."<\n";
?>