note 98170 added to language.variables

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.