Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You seem to misunderstand array versus string. </p> <p>Array<br> <a href="http://php.net/manual/en/language.types.array.php" rel="nofollow">http://php.net/manual/en/language.types.array.php</a> </p> <p>String (in variable)<br> <a href="http://www.php.net/manual/en/language.variables.basics.php" rel="nofollow">http://www.php.net/manual/en/language.variables.basics.php</a> </p> <p>You can use the variable and string approach you currently have, but in honesty you're setting yourself up for a world of pain by having what is affectively different keys and values in single variable/string. This is what arrays are for! </p> <p>A string is a single entity, maybe many chars or words etc, but should be used when you want one thing. $TheName = "Bob";<br> An array is when you want to store, manipulate and make use of several strings or data sets in one go. ie a load of database results. </p> <p>As such, it seems to me you need to use an array. For your code to be an array, you would do something such as: </p> <pre><code>$array = array( "test type" =&gt; "human", "number of participants" =&gt; "2 persons", "additional" =&gt; "$50" ); </code></pre> <p>The KEY of the array is the first text in "", then you assign a VALUE to that KEY by using <code>=&gt;</code>, then the next text in quotes is the VALUE. You separate each KEY and VALUE pair with a comma, the final KEY and VALUE pair in the array does not need a comma. </p> <p>This above is created manually, however you can create this in a loop from a database query. Replacing the manually assigned KEY names as above with perhaps the database column name, and the VALUE would likely be the field's data. </p> <p>As for your question "get specific data from array", you would then loop the array, echoing or assigning each KEY's VALUE to a variable.<br> eg</p> <pre><code>foreach ($array as $key =&gt; $value) { echo "The ."$key." is ".$value; } </code></pre> <p>You really need to read some tutorials on the basics. This is a Q&amp;A site and while we'll help you with questions you have, you do need to understand the basics of what you're coding before you can ask a question about it.<br> As with above, the answer then is not an answer to a question but a guide or tutorial that can already be found on Stack Exchange sites, forums and tutorials :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload