note 98170 deleted from language.variables by visualmind

From: Date: Sun, 30 May 2010 08:42:19 +0000
Subject: note 98170 deleted from language.variables by visualmind
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169722@lists.php.net to get a copy of this message
Note Submitter: mikael dot risenfors at hotmail dot com ---- Since I've found no function for getting variables out of a text (i.e. you have a .txt-file full of "id=22&name=Mikael&age=18&sex=male" and want only the age), I made a simple (but confusing) function. Import the whole text into variable $textpage and call function through: <?php txtVariable($textpage, $wantedVariable); ?> which calls function: <?php function txtVariable($wholeText, $vari){ echo(substr($wholeText, strpos($wholeText, $vari."=")+strlen($vari)+1,strpos($wholeText, "&",strpos($wholeText,$vari."="))- strpos($wholeText,$vari."=")-strlen($vari)-1)); } ?> Example: <?php txtVariable("name=Mikael&age=18&rating=fail", "age"); ?> would return 18

« previous php.notes (#169722) next »