A config is loaded onto the page, in which it is written:

$shortText = '$value["description"]'; $mystring = mb_substr($shortText,0,11); 

Then:

 $sql = 'SELECT * FROM tasks'; $sqlInquiry = mysqli_query($connect,$sql); while ($value = mysqli_fetch_assoc($sqlInquiry) ){ $tasks[] = $value; } 

Then:

 <?php foreach ($tasks as $value): ?> <h2><a href="singlTask.php?id=<?=$value['id']?>"><?=$value['title']?></a></h2> <p><?=$mystring?></p> </div> </li> <?php endforeach;?> 

As a result, the text is displayed: $value["description"] , if I remove single brackets - emptiness.

  • All actions are performed sequentially, if you assigned something to the variable $ value [xxx] at the beginning, then there will be the value that was in it at the time of the assignment. And then the h in it will be later in the cycle it will be in it later and will not affect the variable of which you assigned something earlier. And about the quotes ... open the first pages of a guide to the basics of php. it says that the text in single quotes is not interpolated and appears "as is", and in double quotes, variable names are interpolated and their contents (for the moment) are put into text - Mike

2 answers 2

And if so:

 $mystring = mb_substr($$shortText,0,11); 

    It turned out like this:

     <?=mb_substr($value['description'],0,10,'UTF-8');?></p>