Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Newbie, Data Question

Status
Not open for further replies.

perlkid

Programmer
Mar 9, 2000
35
US

In perl I could just go

foreach $line (@data){
(@res)=split(/\|/, $line);
}

To Loop through the data and find certain lines that I need.

How can I do this with php, I learned how to open data bases, (flat file only) but now how can I look in the first field and find a username and then the password for that username in the second field?

So basically how do I loop through data?

perlkid [sig]<p>Tony<br><a href=mailto:tony@seeki.com>tony@seeki.com</a><br>Experienced In: Perl, JavaScript, C++, PHP<br>
Want More Experience In: Pascal, Python, PHP More C++[/sig]
 
Hi perlkid,

you can use the explode function.

$db_line = &quot;user_id|user_password&quot;;
$user_info = explode(&quot;|&quot;, $db_line);


or use the split function,
both return an array.

cheers


[sig]<p>Ken<br><a href=mailto:admin@mysqlwebring.com>admin@mysqlwebring.com</a><br><a href= Webring</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top