Jump to content

preg_match

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Ricardo-san

Ricardo-san

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
I'm having a bit of a dilemma extracting data from a variable...
So basically. First I'm echoing a variable, then I'm getting a something like this:
+===================================+

| New Account Info                  |

+===================================+

| Domain: auobui.com

| Ip: 174.132.240.50 (n)

| HasCgi: y

| UserName: iub2

| PassWord: teqy%ugana%u

| CpanelMod: x3

| HomeRoot: /home

| Quota: 500 Meg

| NameServer1: ns1.kh3.us

| NameServer2: ns2.kh3.us

| NameServer3: 

| NameServer4: 

| Contact Email: auib@uibfib.com

| Package: kh3us_KH1

| Feature List: default

| Language: english

+===================================+

However! In the browser it shows up like:
+===================================+ | New Account Info | +===================================+ | Domain: auobui.com | Ip: 174.132.240.50 (n) | HasCgi: y | UserName: iub2 | PassWord: teqy%ugana%u | CpanelMod: x3 | HomeRoot: /home | Quota: 500 Meg | NameServer1: ns1.kh3.us | NameServer2: ns2.kh3.us | NameServer3: | NameServer4: | Contact Email: auib@uibfib.com | Package: kh3us_KH1 | Feature List: default | Language: english +===================================+
And is very difficult to read...the problem is, the data is all stored in one variable, not an array, so I can't pull out bits of data and format. I'm thinking maybe I can use preg_match to lookup "Username:" and then store the consequential data (in this case, iub2) in a variable so I can use it in my script...
Any ideas how I would get this done?

#2
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
hmm, theres a workaround it
you can split that variable using "|" sign as seperator, and ignore the first two indexes
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'd do a preg replace: "^(.*)$" replaced with "$1<br />"
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
you might be able to use nl2br($variable) depending on how the data is actually formatted. Some things like to use \n to format data which doesn't get parsed by the browser. nl2br will replace the line feeds with a <br />

#5
Ricardo-san

Ricardo-san

    Learning Programmer

  • Members
  • PipPipPip
  • 53 posts
*sigh*
And to think I spent so long trying to find a solution...when the answer is not in PHP, but HTML.
Thanks for all the answers guys, I got it working.

#6
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
How did you end up fixing it?