I have array
[Company] => Demo Company 1
[First Name] => Test
[Last Name] => Lead 1
[Designation] => This is testing title 1
[Email] => email1@yopmail.com
[Phone] => 242377
I used extract() function so all the index values will become variable names, I also used {} as there are spaces in variable names. But i dont know why its not working 🙁
This ${‘First Name’} returns blank…below is my code
foreach($vals as $value){
extract($value);
echo '<tr><td><a href="edit.php?id='.$LEADID.'">'.${'First Name'}.' '.${"Last Name"}.'</a></td><td>'.$Company.'</td><td>'.$Phone.'</td><td>'.$Email.'</td></tr>';
}
Variable names cannot contain spaces. For reference, read the manual on variables:
If I were you, I’d just go with a shorter name on the array, so instead of
$valueuse$vor similar. You can also use printf to make the code more readable: