I want to smart function Laravel. It is very simple
This example function manual PHP
function add_var_to_url($variable_name,$variable_value,$url_string){
// first we will remove the var (if it exists)
// test if url has variables (contains "?")
if(strpos($url_string,"?")!==false){
$start_pos = strpos($url_string,"?");
$url_vars_strings = substr($url_string,$start_pos+1);
$names_and_values = explode("&",$url_vars_strings);
$url_string = substr($url_string,0,$start_pos);
foreach($names_and_values as $value){
list($var_name,$var_value)=explode("=",$value);
if($var_name != $variable_name){
if(strpos($url_string,"?")===false){
$url_string.= "?";
} else {
$url_string.= "&";
}
$url_string.= $var_name."=".$var_value;
}
}
}
if(strpos($url_string,"?")===false){
$url_string .= "?".$variable_name."=".$variable_value;
} else {
$url_string .= "&".$variable_name."=".$variable_value;
}
return $url_string;
}
Don't fully understand question, but have a look:
$areturn = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo "<br>";
$haystack = $areturn;
$needle = '?';
$pos = strripos($haystack, $needle);
if ($pos === false) {
$areturn = $areturn."?p=1&t1=".$t1;
Session::put('areturn', $areturn);
} else {
Session::put('areturn', $areturn);
}
echo "here is a return: ".Session::get('areturn');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community