0

HTML

<input type='text' name='title[]' value='Some word and another'>

PHP

$title = $xpath->query('//input')->item(0); 
echo $title = $title->getAttribute('value')

RESULT

Some

I NEED TO GET

Some word and another

PROBLEM For some reason everything after first space is stripped out..

RhymeGuy
  • 2,102
  • 5
  • 32
  • 62

1 Answers1

1

Be sure to load it as HTML, so that it allows you to use single quotes:

$dom = new DOMDocument;
$dom->loadHTML("<input type='text' name='title[]' value='Some word and another'>");

$xpath = new DOMXpath($dom);

echo $xpath->query('//input')->item(0)->getAttribute('value');

See it here in action: http://codepad.viper-7.com/pcs3or

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292