Hello I have a problem with this function I want to show the result of the function to put in a variable and send it to the database but it does not show me anything you can see in the example in the Second Block when I added echo its show me but I don't know how to get that result out I did use return but it gave a different result
$fullname = "Ayoub Chafik" ;
function orderID($data){
$AKK = "AK". date('YmdHis');
$string = strtoupper($data);
$strs=explode(" ",$string);
foreach($strs as $str)
$str[0];
}
// I want to see resulte here of this function
echo orderID($fullname) ;
?>
This is the second Block
<?php
$fullname = "Ayoub Chafik" ;
function orderID($data){
echo $AKK = "AK". date('YmdHis');
$string = strtoupper($data);
$strs=explode(" ",$string);
foreach($strs as $str)
echo $str[0];
}
echo orderID($fullname) ;
?>
return $str[0];at the end of the function$str[0]is underforeachloop, it return the first element value. It won't continue the loop. You can create variable and store the values & at the end return the new varaible