1

In my project a file contains content like

&lbl1=Mount Olympus - 24" long x 48" wide - Oil on canvas&prc1=725&sold1=&

&lbl2=Edgartown Marsh 1 - oil on canvas (matted unframed) size: 5 ½" x 5 ½"&prc2=425&sold2=SOLD&

and so and so..

I need to display Mount Olympus - 24" long x 48" wide - Oil on canvas,725 and so and so

is it possible?

i have first read the content from that file and then tried to explode with & ie $arrayNewLine=explode("&",$newLine);

But it's not my result.

Des anyone know this?

2
  • could you please post your result? you can print it with debug($arrayNewLine); Commented Mar 31, 2011 at 7:18
  • @Daren: debug? Not aware of that function.... don't you mean var_dump? Or print_r? And what do you think the result is? He's splitting it on ampersands..you can do that in your head. Commented Mar 31, 2011 at 7:20

3 Answers 3

2

That looks like a URL query string. Try decoding it?

Sign up to request clarification or add additional context in comments.

Comments

2

You can do with file_get_contents and parse_str()

    $data=file_get_contents('finename.ext');

    parse_str($data,$parsed_data);

    print_r($parsed_data);

Comments

0

The parse_str function is what you're after.

Alternatively, you could iterate like so:

$labels = array();

foreach (explode('&', $newLine) as $item) {
    list($name, $value) = explode('=', $item);
    $labels[$name] = $value;
}

Now you have an indexed array of labels. If you want all of the values as a string, try

implode(', ', $labels);

Good luck!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.