Jump to content
php.lv forumi

mainīgais iekš mainīgā


SaMay

Recommended Posts

Tev nevajag mainīgo iekš mainīgā. Tev vajag masīvu iekš masīva:

$kkas = array();
$kkas["cits"] = array();
$kkas["cits"][0] = "nulle";
$kkas["cits"][1] = "viens";
$kkas["cits"][2] = "divi";

$kk = "cits";
$id = 1;

echo $kkas[$kk][$id]; // izvadīs "viens"

Link to comment
Share on other sites

J0ke, tā var gadīties nelabas lietas. Piemēram, ja vienam sākums ir XY, un beigas ZW, bet otram ir sākums XYZ, un beigas W.

Tavā $mas masīvā tie norādīs uz vienu un to pašu elementu:

$mas['XY' . 'ZW']='nono';
$mas['XYZ' . 'W']='yesyes';

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...