note 98170 added to language.variables

From: Date: Sat, 29 May 2010 22:00:27 +0000
Subject: note 98170 added to language.variables
Groups: php.notes 
Request: Send a blank email to php-notes+get-169716@lists.php.net to get a copy of this message
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 ---- Server IP: 69.147.83.197 Probable Submitter: 90.230.93.144 ---- Manual Page -- http://www.php.net/manual/en/language.variables.php Edit -- https://master.php.net/note/edit/98170 Del: integrated -- https://master.php.net/note/delete/98170/integrated Del: useless -- https://master.php.net/note/delete/98170/useless Del: bad code -- https://master.php.net/note/delete/98170/bad+code Del: spam -- https://master.php.net/note/delete/98170/spam Del: non-english -- https://master.php.net/note/delete/98170/non-english Del: in docs -- https://master.php.net/note/delete/98170/in+docs Del: other reasons-- https://master.php.net/note/delete/98170 Reject -- https://master.php.net/note/reject/98170 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169716) next »