Hi everyone,
I am trying to construct some PHP which can search for a specific word within a bit of chunk of data which I am calling using this code:
<?php
include "./auth.php";
x_load("order");
$order_data = func_select_order(Order Number goes Here);
echo $order_data["details"];
?>
That code basically calls up credit card details of Customer X which is as far as I've gotten.
The next step is to take that data and search for the word "{CardNumber}:" and then capture the first six digits which come immediately after. I then need to be able to take those six digits and pass them into a string of an <a href=""> call that comes later in the page.
I'm completely lost though...any ideas?
Using PHP to find a word and then capture data which follows
Moderator: General Moderators
-
tqualizerstore
- Forum Newbie
- Posts: 1
- Joined: Sat Nov 01, 2008 12:28 pm
Re: Using PHP to find a word and then capture data which follows
I use the following to strip unique tags out of xml strings. maybe you could adapt it to your needs:
using something like - $the_bit_i_want = getTag({tag_text}, {string});
Hope this helps....
Code: Select all
function getTag($tag_name, $contents)
{
$start_tag = "<" . $tag_name . ">";
$end_tag = "</" . $tag_name . ">";
$start_tag = "<" . $tag_name . ">";
$end_tag = "</" . $tag_name . ">";
// explode at opening tag
$ex_content = explode($start_tag, $contents);
// explode at closing tag
$ex2_content = explode($end_tag, $ex_content[1]);
// get the bit in the middle
$tag = $ex2_content[0];
return $tag;
}
$the_bit_i_want = getTag({tag_text}, {string});
Hope this helps....
Re: Using PHP to find a word and then capture data which follows
Code: Select all
$cardno = substr($order_data["details"], strpos('{CardNumber}:'), 6);